How to install PostgreSQL 14 on Ubuntu

In this article, we have shown how to install PostgreSQL 14 on Ubuntu step by step.

How to install PostgreSQL 14 on Ubuntu

1. Go to official PostgreSQL website .

2. Run the following command to create the repository file conifugraiton.

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

How to install PostgreSQL 14 on Ubuntu

3. Import the repository signing key by running key.

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

4. Now, update the package list by running below command.

sudo apt-get update

5. Now install PostgreSQL and its extensions by running below command.

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

PostgreSQL post installation steps

1. Enable PostgreSQL service on Ubuntu by running below command.

sudo systemctl enable postgresql

2. Check the PostgreSQL service is running or not.

sudo systemctl status postgresql

If it is not running run the below command.

sudo systemctl statrt postgresql

Connect to PostgreSQL Server after installation

1. Switch to user postgres by running below command.

sudo su - postgres

2. Now type psql and hit enter.

3. Now, we have to verify whether installed PostgreSQL version is 14 or not by running below command.

select version();

4. Now, change the password of postgres user.

alter user postgres with password 'admin@123';

So in this article, we have seen how to install PostgreSQL 14 on Ubuntu and performed PostgreSQL post installation steps.