Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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?

like image 846
Dave A Avatar asked Jan 24 '26 19:01

Dave A


1 Answers

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).

like image 53
Craig Ringer Avatar answered Jan 26 '26 09:01

Craig Ringer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!