PostgreSQL Installation

This page covers the basic installation process for PostgreSQL.

Install on Ubuntu

sudo apt update
sudo apt install postgresql postgresql-contrib

Check service status

sudo systemctl status postgresql

Start PostgreSQL

sudo systemctl start postgresql

Enable PostgreSQL on boot

sudo systemctl enable postgresql

Switch to postgres user

sudo -u postgres psql

Check PostgreSQL version

psql --version

Default port

PostgreSQL usually runs on port 5432.

Connect to a database

psql -h 127.0.0.1 -U myuser -d mydb

Common installation checks

ss -ltnp | grep 5432

Common issues after installation

  • Connection refused
  • Password authentication failed
  • Database does not exist