Up to 50% off all plan, limited-time offer. Starting at $2.48.

PostgreSQL

An advanced open-source relational database management system.

Login to PostgreSQL Shell

sudo -iu postgres psql

Useful commands:

  • l: List all databases
  • c DB_NAME: Connect to a specific database
  • dt: List all tables in the current database
  • d TABLE_NAME: Show structure of a table
  • du: List all database roles/users
  • password USERNAME: Change password for a role
  • q: Quit psql shell

Example Session

sudo -iu postgres
psql
l                       # List databases
c mydatabase            # Connect to your DB
dt                      # List tables
d mytable               # Describe table structure
q                       # Quit

Connect to a Specific Database as a User

psql -h <host> -p <port> -U <username> -d <database>
  • -h <host> → Hostname of the PostgreSQL server (e.g., localhost)
  • -p <port> → Port (default: 5432)
  • -U <username> → Database user
  • -d <database> → Database name to connect to

Key Locations

  • Credentials: /root/.cloudzy-creds
  • Config: /etc/postgresql/*/main
  • Data: /var/lib/postgresql
  • Logs: /var/log/postgresql

Application Details