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

Abhijeet Kasurde
  • 983
  • 9
  • 20
Ajo Augustine
  • 1,262
  • 4
  • 16
  • 21

1 Answers1

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).

Daniel Vérité
  • 3,045
  • 16
  • 19