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
Asked
Active
Viewed 252 times
0

Abhijeet Kasurde
- 983
- 9
- 20

Ajo Augustine
- 1,262
- 4
- 16
- 21
-
Why do you need to have user other than `postgres`? – Abhijeet Kasurde Apr 03 '14 at 10:55
-
to maintain a policy – Ajo Augustine Apr 03 '14 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. – Stefan Lasiewski Apr 04 '14 at 16:52
1 Answers
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