20

I'm currently trying to run postgresql (9.3) on my iMac but I have some issues with user postgres and psql connection.

I bought an iMac old generation (with snow Leopard) that was migrated to Lion. As followed on other StackOverflow topics I added this line on my .bash_profile :

export PATH=/Library/PostgreSQL/9.3/bin:/usr/bin:$PATH

When launching pg :

sudo su postgres -c '/Library/PostgreSQL/9.3/bin/pg_ctl -D /Library/PostgreSQL/9.3/data/ -m fast start'

it returns :

su: unknown login: postgres

What should I do ?

2
  • You need to create a user account called postgres on the system, or connect to postgresql using a different account that already exists (assuming it has permission for the operation). Commented May 22, 2013 at 10:57
  • 2
    PostgreSQL 9.3 is a beta version which at this time, should be used only to test and report bugs to the PostgreSQL developers. Use 9.2 instead. Commented May 22, 2013 at 13:02

3 Answers 3

34

The default postgres user in OSX 10.8 & 10.9 should be _postgres, you can use sudo -u _postgres to run the command

Sign up to request clarification or add additional context in comments.

1 Comment

This is what I was missing
23

I got this same error (su: unknown login: postgres) when trying sudo su - postgres. I then managed to log in using sudo psql -U my.username postgres.

I could then create the appropriate users, etc.

Hope that helps.

Comments

0

Try to start from current user:

/Library/PostgreSQL/9.3/bin/pg_ctl -D /Library/PostgreSQL/9.3/data/ -l /usr/local/var/postgres/server.log start

Additional info: How to start PostgreSQL server on Mac OS X?

4 Comments

I tried this command line but there is no /bin directory in PostgreSQL/9.3. Should I add it ? I did probably a mistake on my bash_profile. I heard also the path /usr/var changed into usr/local/var on Lion. Could it come from this ?
@user1713964 No, it seems your postgresql installation broken. Why not remove old installation and install using homebrew (brew.sh) package manager? brew install postgresql --without-ossp-uuid
Just did it and I have same issue :/
I installed with homebrew and there is no /Library/PostgreSQL/9.x/data/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.