Skip to content

Instantly share code, notes, and snippets.

@poteto
Created August 24, 2012 08:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poteto/3447677 to your computer and use it in GitHub Desktop.
Save poteto/3447677 to your computer and use it in GitHub Desktop.
new postgres db on local machine

Creating a new local pg database:

$ sudo su - postgres
# log in as postgres

$ createuser
# Enter name of role to add: username
# Shall the new role be a superuser? (y/n) n
# Shall the new role be allowed to create databases? (y/n) n
# Shall the new role be allowed to create more new roles? (y/n) n
# CREATE ROLE

$ createdb databasename
# CREATE DATABASE

$ psql
# enter postgres=#

$ alter user username with encrypted password 'password';
# ALTER ROLE
$ grant all privileges on database databasename to username;
# GRANT

$ \q
# exit psql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment