Logged in as postgres but getting the error createuser: creation of new role failed: ERROR: must be superuser to create superusers

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;


On Mac OS default installation

The default superuser is not postgres, but the current mac-os user. In order to solve that:

1 . Connect to your DB with your current (system) user. The below example connects to DB named "postgres":

psql -d postgres

you should get into psql prompt, like postgres=#

2 . Grant superuser to well-known postgres username:

ALTER ROLE postgres superuser;

If everything went smoothly, you'll see the response: ALTER ROLE

3 . Enjoy! (\q to quit)