tags:

views:

127

answers:

3

Hi all, How does one go about disabling a super user account within postgres without deleting it. I looked at the Alter Role documentation and I am drawing blanks. In addition this is the only super user account and the subordinate accounts own the tables that they are responsible for

+1  A: 

I assume that you have created a new user with super user privileges and you don't want to disable the postgres account, right?

To disable an account try revoke:

REVOKE ALL PRIVILEGES
ON DATABASE mydb
FROM mysuperuser;

I might have missed something in the snippet above, check out the docs here: http://www.postgresql.org/docs/8.4/static/sql-revoke.html

To remove the user, become super user yourself, ie postgres. Then use DROP ROLE:

DROP ROLE mysuperuser;

http://www.postgresql.org/docs/8.4/interactive/sql-droprole.html

John P
+1  A: 

There is always a superuser, you can't maintain your database without this role.

Frank Heikens
Any documents to validate this?
Woot4Moo
Just check the manual, many statements need a superuser (CREATE LANGUAGE is one of them) and you need a superuser to create a superuser role. Without a superuser, you're on a dead end street.
Frank Heikens
Thanks. So logically my argument is going to be that a non super user does not have the necessary rights to grant privileges back to my super user in the case of maintenance
Woot4Moo
+2  A: 

You could configure pg_hba.conf to reject the super user so it can't log in.

xenoterracide
Indeed. Disabling login would effectively disable the account. Also seems to be the pattern Linux and some Windows installations follow.
aib