Skip to content

Instantly share code, notes, and snippets.

@samsch

samsch/.md Secret

Created March 19, 2018 12:22
Show Gist options
  • Save samsch/3e757528cf30f9b3f49cfbb03bd49503 to your computer and use it in GitHub Desktop.
Save samsch/3e757528cf30f9b3f49cfbb03bd49503 to your computer and use it in GitHub Desktop.
Creating a new user+db in postgres

Login to postgres with an administrative user. For a default Ubuntu installation, you can do this with sudo -u postgres psql.

  1. Create user: create user <username> with password '<secure password>';
  2. Create DB: create database <db name> with owner <username> encoding 'UTF-8';
  3. Exit with \q

Test the connection with your new user: psql -U <username>.

If the database isn't accessible via the default port on localhost/127.0.0.1, then use the host -h flag to psql to connect. Obviously the local postgres user login won't work :P.

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