Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postgres: upgrade a user to be a superuser?

Tags:

sql

postgresql

In postgres, how do I change an existing user to be a superuser? I don't want to delete the existing user, for various reasons.

# alter user myuser ...? 
like image 956
flossfan Avatar asked May 25 '12 15:05

flossfan


People also ask

Is postgres user a superuser?

A superuser in PostgreSQL is a user who bypasses all permission checks. Superusers can run commands that can destabilize or crash the database server (e.g., create C functions) and access the operating system. Show activity on this post.

Where is super user in PostgreSQL?

Using psql command Enter password to log into PostgreSQL. Enter \du command to list all users in PostrgeSQL. You will see the list of all users and roles. If you want more information such as description for each user, enter \du+ command.

How do you make a superuser in Pgadmin?

Click the expand arrow next to your database > expand 'Schemas' > right-click 'public' > select 'Grant Wizard'. On the 'Selection' tab click 'Check All'. In the 'Privileges' tab select the newly created group from the 'Role' drop-down menu > check the 'Select' box > click 'Add/Change' > click 'OK'.


2 Answers

To expand on the above and make a quick reference:

  • To make a user a SuperUser: ALTER USER username WITH SUPERUSER;
  • To make a user no longer a SuperUser: ALTER USER username WITH NOSUPERUSER;
  • To just allow the user to create a database: ALTER USER username CREATEDB;

You can also use CREATEROLE and CREATEUSER to allow a user privileges without making them a superuser.

Documentation

like image 21
ZZ9 Avatar answered Sep 20 '22 12:09

ZZ9


ALTER USER myuser WITH SUPERUSER; 

You can read more at the Documentation

like image 78
Quassnoi Avatar answered Sep 20 '22 12:09

Quassnoi