Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
Why do you need to have user other than postgres? –  Abhijeet Kasurde Apr 3 at 10:55
    
to maintain a policy –  Ajo Augustine Apr 3 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 4 at 16:52

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
Thanks Daniel. It worked and this was what I was looking for. –  Ajo Augustine Apr 11 at 7:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.