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 ...?
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.
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.
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'.
To expand on the above and make a quick reference:
ALTER USER username WITH SUPERUSER;
ALTER USER username WITH NOSUPERUSER;
ALTER USER username CREATEDB;
You can also use CREATEROLE
and CREATEUSER
to allow a user privileges without making them a superuser.
Documentation
ALTER USER myuser WITH SUPERUSER;
You can read more at the Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With