Skip to content

Instantly share code, notes, and snippets.

@bf
Last active June 21, 2016 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bf/c545ed5b817e113505f7b1fb302b6ab2 to your computer and use it in GitHub Desktop.
Save bf/c545ed5b817e113505f7b1fb302b6ab2 to your computer and use it in GitHub Desktop.
PostgreSQL: Create new User and Database
# To create a new postgres database with a new user/password combination
# we first have to log in as the postgres user
sudo su - postgres;
# now we are the "postgres" user which is allowed to create new database users
# we use the -P parameter to create a new user called "annie". Annie uses a password.
createuser -P annie;
# finally, we create Annie's database
createdb -O annie annies_database;
# in the end we exit the postgres user's shell and
# we become ourselves again
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment