Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I get superuser rights on postgres. I am among sudoers in Linux, but I don't have rights to create users in postgres. How can I gain superuser rights in postgres?

This is my pg_hba.conf:

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD                                                                                                 

# "local" is for Unix domain socket connections only                                                                                                         
local   all         all                               ident sameuser                                                                                         
# IPv4 local connections:                                                                                                                                    
host    all         all          trust                                                                                                  
# IPv6 local connections:                                                                                                                                    
host    all         all         ::1/128               md5
share|improve this question

Postgres has it's own "admin" user which is in principal unrelated to the system admin or root user. When you set-up your postgres instance its admin user was very probably created (for you), so best check with your installation or distribution docs what his password was.

share|improve this answer

The account postgres should have superuser like permissions regarding postgreSQL, try logging in as postgres and giving it a shot.

share|improve this answer

The internal Postgres roles are essentially unrelated to the operating system accounts. That said, many distributions do try to set up the database superuser account to correspond with an operating system account; looking at your pg_hba.conf setting, it's likely that you need to sudo to the postgres user (OS level), and then log into the database with psql. This is because you're currently set to authenticate using "ident sameuser" which means (in simplified explination) that to connect from the local box, you need your database role to match the operating system user account. This may or may not be something you want to continue going forward; I'd recommend reading this:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.