Skip to content

Instantly share code, notes, and snippets.

@Lumbe
Last active October 23, 2017 10:49
Show Gist options
  • Save Lumbe/d3dba1fc1fce4b24fe38290f35bd9011 to your computer and use it in GitHub Desktop.
Save Lumbe/d3dba1fc1fce4b24fe38290f35bd9011 to your computer and use it in GitHub Desktop.
Create PostgreSQL user and database

Create PostgreSQL user and database for development environment

1. Install PostgreSQL

$ sudo apt-get update
$ sudo apt-get install postgresql postgresql-contrib

2. Switch to postgresql user

$ sudo -i -u postgres

Now you can use psql

3. Create user (not in psql) with same name that is used in Unix system

$ createuser --interactive
Enter name of role to add: lumen
Shall the new role be a superuser? (y/n) y

More info man createuser

4. Create database with owner and locale

createdb db_name --owner=lumen --locale=ru_RU.utf8 --template=template0

More info man createdb You can list available locales with locale -a

template0 is used to bypass locale incompatible error

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