How to install and configure PostgreSQL 16 on Ubuntu 22.04

In this article, we have shown how to install and configure PostgreSQL 16 on Ubuntu 22.04 step by step.

PostgreSQL is a powerful, open source object-relational database system with over 35 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.

Install PostgreSQL 16 on Ubuntu 22.04

1. Create the file repository configuration:

sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

How to install and configure PostgreSQL 16 on Ubuntu 22.04

2. Import the repository signing key:

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

3. Update the package list:

sudo apt-get update

4. Now install PostgreSQL 16 on Ubuntu 22.04 using below command.

sudo apt-get install -y postgresql-16 postgresql-contrib-16

Post installation steps of PostgreSQL 16 on Ubuntu

1. LEts verify postgreSQL 16 status on Ubuntu by running below command.

sudo systemctl status postgresql

2. Connect to PostgreSQL 16 on Ubuntu 22.04:

sudo su - postgres psql

3. lets vetrify the PostgreSQL version installed on Ubuntu Linux:

SELECT version();

4. Set the password for the user postgres which is the superuser.

alter user postgres with password 'admin@123';

For more information about PostgreSQL post installation steps, please below video: