Postgres createuser wants a password (not my system password)

harumph picture harumph · Oct 17, 2012 · Viewed 7k times · Source

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

Answer

Jason Swett picture Jason Swett · Oct 17, 2012

I usually do it like this:

createuser -P -s -e myuser

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