I need to create a superuser so I can create a db, but I'm having trouble with this. I'm logged in as the user postgres:
sudo su - postgres
But when I try to create a superuser, I get the following problem:
$createuser glassboard;
Shall the new role be a superuser? (y/n) y
createuser: creation of new role failed: ERROR: must be superuser to create superusers
This also happens if I try to create a new user in psql and then make him a superuser:
$ psql -U postgres
psql (9.1.4)
Type "help" for help.
postgres=> create user glassboard
postgres-> ;
ERROR: permission denied to create role
How do I create a superuser?
output of \du
in postgres:
postgres=> \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
main | Superuser, Create role, Create DB, Replication | {}
postgres | | {}
Some OSX packages don't create a postgres
superuser database account. The superuser is named differently, in your case it's main
.
When you do psql -U main
without specifying a database, it defaults to the same name as the user.
If you don't have a database named main
, indicate a different database with the -d
option.
If you have no database to connect to, use template1
psql -U main -d template1
If still you want to grant superuser to postgres
, do once logged inside psql:
alter user postgres superuser;
In my case on PostgreSQL 9.2, the postgres
superuser was created, but when I went to create additional superusers from the postgres
user, I was never prompted with Shall the new role be a superuser? (y/n)
so the new user was created with default permissions. To fix this, I just ran this command as the postgres
user: ALTER USER myuser WITH SUPERUSER;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With