Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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         127.0.0.1/32          trust                                                                                                  
# IPv6 local connections:                                                                                                                                    
host    all         all         ::1/128               md5
share|improve this question

3 Answers 3

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: http://www.depesz.com/index.php/2007/10/04/ident/

share|improve this answer

Your Answer

 
discard

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.