简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM