2

I installed the latest version of postgres on OS X Lion using homebrew. The path is correct:

$ which postgres
/usr/local/bin/postgres
$ which psql
/usr/local/bin/psql

and brew doctor is happy. However, when I try to create a user, this happens:

$ createuser myuser
Password:
createuser: could not connect to database postgres: FATAL:  password authentication failed for user <$USER>

The password is definitely not my regular user password and I have no idea how to find out what it's supposed to be. It's possible that I used homebrew to install a different version of postgres some time ago while installing a bunch of other stuff, but I don't recall. I did notice a different version of 'postgresql' that was installed alongside the new version of 'postgres', which I removed.

Don't know if this is a clue, but when I do this:

$ sudo su - postgres

The path to psql (but not postgres) is no longer correct:

postgres$ which postgres
/usr/local/bin/postgres
postgres$ which psql
/usr/bin/psql

Might be something simple. Would appreciate any help. Thanks!

Mac OS X Lion 10.7.5
homebrew 0.9.3
postgres 9.2.1
Igor
  • 33,276
  • 14
  • 79
  • 112
harumph
  • 169
  • 3
  • 10
  • Just out of curiosity, have you already created a database cluster? http://www.postgresql.org/docs/8.3/static/creating-cluster.html – Jason Swett Oct 17 '12 at 15:21
  • yes (after fixing shared memory). – harumph Oct 17 '12 at 15:52
  • Can you do `sudo createuser ...`? – Jason Swett Oct 17 '12 at 17:43
  • 1
    And I might try doing `sudo passwd postgres` so you know what the password for `postgres` is. Maybe that's what it's asking you for. – Jason Swett Oct 17 '12 at 17:44
  • Gah! Both suggestions seemed really promising, but password authentication fails regardless of which user I'm using and if I set the password using sudo passwd. – harumph Oct 17 '12 at 18:09
  • If you set the password for `postgres`, can you at least do `su postgres` successfully? – Jason Swett Oct 17 '12 at 18:09
  • Yes, thanks. I had to sudo su before, but now su postgres works with the password I just set. Still need some other password to create a new user though. – harumph Oct 17 '12 at 18:15
  • These are all guesses, as I'm sure you're aware, but have you tried restarting PostgreSQL since you changed the `postgres` user's password? And this is totally wacky, but I might even just restart my entire computer at this point. – Jason Swett Oct 17 '12 at 18:29
  • Yo might take a look at [this answer](http://stackoverflow.com/a/7696398/947357) which should be generic enough for OS X. – A.H. Oct 17 '12 at 19:50

2 Answers2

7

I usually do it like this:

createuser -P -s -e myuser

http://www.postgresql.org/docs/8.4/static/app-createuser.html

Jason Swett
  • 43,526
  • 67
  • 220
  • 351
  • 1
    After adding a password for the new role, I still get prompted for a password that I don't know. – harumph Oct 17 '12 at 15:11
1

I solved the problem: I had to stop the server for the old version of postgres that came with my system. I didn't realize it, but I guess it starts on system start. Now I'm not having a problem.

harumph
  • 169
  • 3
  • 10