How to install PostgreSQL 13 on Ubuntu 20.04

In this article, we will see how to install PostgreSQL 13 on Ubuntu 20.04.

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

1. Create the file repository configuration:

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

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 lists:

sudo apt-get update

4. Install the latest version of PostgreSQL.

sudo apt-get -y install postgresq

If we want a specific version, use ‘postgresql-12’ or similar instead of ‘postgresql’.

5. Verify PostgreSQL installed or not.

apt --installed list | grep postgresql

PostgreSQL Post Installation Steps:

1. How to check PostgreSQL Server Status:

pg_ctlcluster 13 main status

How to install PostgreSQL 13 on Ubuntu 20.04

or

systemctl status postgresql

2. Switch to postgres user

su - postgres

3. Connect to PostgreSQL server by using psql tool.

psql

Set the password for ‘postgres’ user

alter user postgres with password 'admin@123';

So, in this article we have shown how to install PostgreSQL 13 on Ubuntu 20.04. Then, performed post-installation steps of PostgreSQL 13.