Forked from ekumachidi/gist:aac9316496fb2ca84dcef00920fede9b
Created
May 18, 2018 11:19
-
-
Save abhijitsinha/69b4fc4bd23b7a7ab8ebbfe0d3b2ffd9 to your computer and use it in GitHub Desktop.
Create new postgres super user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run this | |
"sudo -u postgres psql" | |
in your terminal to get into postgres | |
postgres=# | |
Run "CREATE USER new_username;" | |
Note: Replace new_username with the user you want to create, | |
postgres=# CREATE USER new_username; | |
CREATE ROLE | |
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; | |
ALTER ROLE | |
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 | {} | |
postgres=# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment