Login: standard access only on local socks connection $ sudo -u postgres psql Login with user $ psql Create new user =# CREATE ROLE ; Create new user who can login and has a password of 'password' =# CREATE ROLE WITH LOGIN PASSWORD 'password'; Enable user to login (if forgotten when creating user) =# ALTER ROLE "" WITH LOGIN; Set password on user =# ALTER ROLE "" WITH ENCRYPTED PASSWORD ''; Create a database $ createdb or =# CREATE DATABASE ; Drop database =# DROP DATABASE ; Add user to database =# grant all privileges on database to Create a table =# CREATE TABLE ( id SERIAL, title TEXT ); Other commands | \? | show help | | \l | list databases | | \q | quit postgres client (psql) | | \c | change active database | | \c | change active database and user | | \d | describe current database (list tables) | | \d | describe table | | \d+
| describe table with extra information | | \du | list of roles | | \du+ | list of roles with description | | \dt | show tables | Disable local login without password Edit config file ///etc/postgresql/9.5/main/pg_hba.conf// (location may differ depending on distro) (type) (db) (user) (address) (method) local all all md5 host all all 127.0.0.1/32 md5 Maybe the following would be better though. Here the default user still has peer access but all others must supply a password. (type) (db) (user) (address) (method) local all postgres peer local all all md5 host all all 127.0.0.1/32 md5