Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch to postgres user on Mac

I would like to su to the postgres user on Mac, so that I can run postgres.

What am I doing wrong here?

delirium:~ anna$ sudo su postgres
delirium:~ anna$

Nothing happens. If I try to run postgres, I then get something like this:

delirium:~ anna$ sudo pg_ctl -D /usr/local/var/postgres -l      
/usr/local/var/postgres/server.log startpg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

If I try this in order to su, I also get an error:

delirium:~ anna$ sudo su - postgres
su: no directory
delirium:~ anna$

What can I do instead? I'm fairly sure that the postgres user exists.

like image 249
flossfan Avatar asked May 25 '12 11:05

flossfan


2 Answers

That looks consistent with the postgres user not having a login shell. Try sudo -u postgres bash

like image 60
Iain Avatar answered Oct 03 '22 23:10

Iain


PostgreSQL is integrated in Server.app available through the App Store in Mountain Lion.

You would have this file: /Library/Server/PostgreSQL/Config/org.postgresql.postgres.plist

You can sudo:

sudo -u _postgres psql template1

Or connect:

psql -h localhost -U _postgres postgres
like image 42
bbaassssiiee Avatar answered Oct 03 '22 22:10

bbaassssiiee