logo

PostgreSQL Cheatsheet

Start server

$ postgres -D /path/to/data

# start in the background
$ postgres -D /usr/local/pgsql/data >logfile 2>&1 &

Check pg_hba.conf

pg_hba.conf controls client authentication (HBA stands for host-based authentication.)

$ find / -name "pg_hba.conf"

pg_hba.conf file format: a set of records, one per line.

Connect to db

$ psql -U <user> -d <database> -h <host>

List database

db=# \l

Check readiness

Use pg_isready