PostgreSQL is a powerful, open-source object-relational database system known for its reliability, extensibility, and standards compliance. PostgreSQL 17 brings performance improvements, new SQL features, and enhanced logical replication. This guide installs it on Ubuntu 26.04 LTS.

Tested and valid on:

  • Ubuntu 26.04 LTS

Prerequisites

  • Ubuntu 26.04 LTS server
  • A user with sudo privileges

Step 1 – Add the PostgreSQL APT Repository

sudo apt install curl ca-certificates -y
sudo install -d /usr/share/postgresql-common/pgdg
curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update

Step 2 – Install PostgreSQL 17

sudo apt install postgresql-17 postgresql-contrib -y

Step 3 – Check Status

sudo systemctl status postgresql
psql --version

Step 4 – Access the PostgreSQL Shell

PostgreSQL creates a system user named postgres. Switch to it:

sudo -i -u postgres
psql

Step 5 – Set a Password for the postgres User

ALTER USER postgres PASSWORD 'NewStrongPass2026!';
q
exit

Step 6 – Create a Database and Role

sudo -i -u postgres
createuser --interactive  # follow prompts
createdb myappdb
psql
GRANT ALL PRIVILEGES ON DATABASE myappdb TO myuser;
q
exit

Step 7 – Allow Remote Connections (optional)

Edit postgresql.conf and pg_hba.conf:

sudo nano /etc/postgresql/17/main/postgresql.conf

Set: listen_addresses = '*'

sudo nano /etc/postgresql/17/main/pg_hba.conf

Add: host all all 0.0.0.0/0 scram-sha-256

sudo systemctl restart postgresql

Conclusion

PostgreSQL 17 is installed and running on Ubuntu 26.04 LTS. Its ACID compliance, powerful query planner, and extensibility make it an excellent choice for complex data workloads, GIS applications, and analytics.