Problems running Postgres “createuser” command
-
19-02-2021 - |
Pergunta
I'm trying to run the createuser
command on an MacOS 10.15 installation of Postgres 11.6. I have enabled root
but there is no postgres
user to su
as - there's a _postgres
user instead:
dd@finglas:~ $ cat /etc/passwd | grep 'post'
_postfix:*:27:27:Postfix Mail Server:/var/spool/postfix:/usr/bin/false
_postgres:*:216:216:PostgreSQL Server:/var/empty:/usr/bin/false
The $PATH
is valid for Postgres tools, and which createuser
points to the correct binary:
dd@finglas:~ $ which createuser
/Applications/Postgres.app/Contents/Versions/latest/bin/createuser
I was expecting to be able to execute something like:
dd@finglas:~ createuser dev_user
I can login to Postgres itself as the postgres
user, but I'm unable to run a createuser
from the terminal. Any suggestions?
Solução
The database user defaults to the same name as your operating system user. Try to specify it explicitly:
createuser -U postgres dev_user
If that causes authentication problens, try again as operating system user _postgres
.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a dba.stackexchange