0

I need to run my current Postgresql 9.3 under a system user other than postgres, say admin OR I need to install Postgresql 9.3 with the default user as say admin on Ubuntu 12.04

3
  • Why do you need to have user other than postgres? Apr 3, 2014 at 10:55
  • to maintain a policy Apr 3, 2014 at 10:55
  • Normally you would just need to create a new user, ensure that the new user can write to the postgres data directories and create a startup script to start postgres as that user. Apr 4, 2014 at 16:52

1 Answer 1

3

An installed PostgreSQL on Debian/Ubuntu is essentially:

  • a set of binaries per version that any user can potentially run to spawn and manage a new instance.
  • a datadir per instance that only its owner can use.

If the initial situation consists of 9.3 binaries being installed through Ubuntu packages, a non-postgres Unix user can spawn an instance by doing:

/usr/lib/postgresql/9.3/bin/initdb --pgdata=$HOME/pginstance [other-options]

Then start this instance with:

/usr/lib/postgresql/9.3/bin/pg_ctl -D $HOME/pginstance start

and stop it with:

/usr/lib/postgresql/9.3/bin/pg_ctl -D $HOME/pginstance stop

Obviously $HOME/pginstance can be wherever the user has the permission to write.

This instance would be unrelated to the postgres user and the scripts that come with the Ubuntu packages wouldn't know or care about it. It's entirely managed by the user who started it. It may coexist with others, but each instance must have its own port (defined in postgresql.conf inside the data directory).

1
  • Thanks Daniel. It worked and this was what I was looking for. Apr 11, 2014 at 7:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .