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 ?

user1713964
  • 1,209
  • 2
  • 14
  • 26
  • 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). – lurker May 22 '13 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. – Daniel Vérité May 22 '13 at 13:02

3 Answers3

34

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

chancyWu
  • 14,073
  • 11
  • 62
  • 81
21

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.

avjaarsveld
  • 579
  • 6
  • 9
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?

Community
  • 1
  • 1
Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
  • 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 May 22 '13 at 11:12
  • 1
    @user1713964 No, it seems your postgresql installation broken. Why not remove old installation and install using homebrew (http://brew.sh) package manager? brew install postgresql --without-ossp-uuid – Valery Viktorovsky May 22 '13 at 11:32
  • Just did it and I have same issue :/ – user1713964 May 23 '13 at 18:01
  • 2
    I installed with homebrew and there is no `/Library/PostgreSQL/9.x/data/` – Kinnard Hockenhull Aug 05 '13 at 03:11