Dave A
Dave A

Reputation: 2830

"sudo: unknown user: postgres" when trying to create postgres user

I'm using Mac 10.9.5 and PostgreSQL 9.3.4. I'm following instructions for installing a third-party software package (Instructure Canvas) on my local machine) and the instructions say to execute:

sudo -u postgres createuser $USER
sudo -u postgres psql -c "alter user $USER with superuser" postgres

but upon executing the first command, I get the error

davea$ sudo -u postgres createuser $USER
sudo: unknown user: postgres

Other posts seemed to indicate I needed to prepend a "_" to my "postgres" user, but upon doing so, i get this error ...

davea$ sudo -u _postgres createuser $USER
createuser: could not connect to database postgres: FATAL:  role "_postgres" does not exist

Any ideas what I need to do to get this to work properly?

Upvotes: 3

Views: 8155

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324541

It looks like whatever you installed has a system user named _postgres and a PostgreSQL user named postgres. Fun!

Try:

sudo -u _postgres createuser -U postgres myusername

(The numerous messy, conflicting and incompatible PostgreSQL installs used on OS X are a nightmare, argh).

Upvotes: 2

Related Questions