psql Command Basics

Source: raw/postgres/psql commands.md.

Service control

sudo service postgresql status
sudo systemctl reload postgresql

Connecting

psql -U postgres                              # default admin user
psql -U username -d database_name             # specific user + db
psql -U username -d database_name -h host -p port   # full connection

Create a database

createdb dbname;

Open questions

  • Common psql meta-commands (\l, \dt, \d, \c, \?).
  • Auth: peer vs md5 vs scram-sha-256; pg_hba.conf.
  • How this relates to Cloudflare Hyperdrive connection strings.