Login to postgres with an administrative user. For a default Ubuntu installation, you can do this with sudo -u postgres psql
.
- Create user:
create user <username> with password '<secure password>';
- Create DB:
create database <db name> with owner <username> encoding 'UTF-8';
- 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.