Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create new postgres super user
Run this
"sudo -u postgres psql"
in your terminal to get into postgres
Run "CREATE USER new_username;"
Note: Replace new_username with the user you want to create,
postgres=# CREATE USER new_username;
Since you want that user to be able to create a DB, you need to alter the role to superuser
postgres=# ALTER USER new_username SUPERUSER CREATEDB;
To confirm, everything was successful,
postgres=# \du
List of roles
Role name | Attributes | Member of
new_username | Superuser, Create DB | {}
postgres | Superuser, Create role, Create DB, Replication | {}
root | Superuser, Create role, Create DB | {}
Copy link

ELHoussineT commented May 22, 2017

Thank you. Pretty clear.

Copy link

miladj3 commented Jul 5, 2021

thank youuu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment