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