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
?