How can i create new Superuser in postgres in par with postgres default user? I want this new user to have its own psw that i can use to access the database created
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Heya,
To create a new superuser, use the
CREATE USER
command along withSUPERUSER
andLOGIN
options, and set the password for the new user. Replacenew_username
with the desired username andyour_password
with the password you want for this new user:Grant privileges to the new user:
This step isn’t always necessary because the
SUPERUSER
role already provides full privileges, but you can explicitly grant all privileges to the new user on a specific database if needed:Exit PostgreSQL:
Once the user has been created, exit the PostgreSQL prompt. Now you can try logging in with the new superuser account by running the following command:
You’ll be prompted to enter the password for
new_username
to access the database.This will create a new superuser with the specified password, allowing you to access the database using this new user.
Heya, @charmeem
You can create the superuser using
CREATE ROLE
You can manage privileges efficiently by creating a group role:
This setup makes it easier to manage superuser-like privileges for multiple users.
Also assign superuser privileges only if absolutely necessary. For less sensitive tasks, consider roles with specific privileges instead.
Hope that this helps!
Hi there,
In addition to what has already been mentioned, if you are using a managed Postgres cluster, you can follow the steps on how to do that here:
- Bobby