PostgreSQL Cheat Sheet - noi-techpark/documentation GitHub Wiki

For Linux Mint / Ubuntu / Debian

Should work on all versions of these Linux distributions.

Create a new database

Assigned to the user postgres:

sudo -u postgres bash
createdb new_database

Assigned to any other user:

createuser my_pguser
createdb -O my_pguser new_database

User handling

Change the user password on database xxx for user yyy:

sudo -u yyy bash
psql xxx
\password yyy

PostgreSQL server service

service postgresql start
service postgresql stop
service postgresql restart
service postgresql reload
service postgresql status