Why doens't my Postgres user have permissions to add a Postgres database?

Posted by orokusaki on Server Fault See other posts from Server Fault or by orokusaki
Published on 2012-12-15T19:19:54Z Indexed on 2012/12/15 23:06 UTC
Read the original article Hit count: 394

First, I ran:

sudo su postgres
createuser -U postgres foouser -P

which worked fine, and I ran:

createdb -U foouser -E utf8 -O foouser foodatabase -T template0

and got "permission denied: cannot create database"

Firstly, should I even su as postgres to do operations like the first one (assuming my postgres data dir is owned by postgres), or is -U postgres from any user (assuming trust is used in pg_hba.conf) sufficient?

Secondly, why am I running into this error? Is this because the user foouser is a non-superuser? Should I create foodatabase using the postgres user and simply -O foouser?

© Server Fault or respective owner

Related posts about linux

Related posts about postgresql