DEV Community

Cover image for Install PostgreSQL 12 on Ubuntu 22.04
Maimoona Abid
Maimoona Abid

Posted on

1

Install PostgreSQL 12 on Ubuntu 22.04

This blog will walk you through the process of installing PostgreSQL 12 on an Ubuntu 22.04. PostgreSQL is one of the most extensively used object-relational database management systems. PostgreSQL 12 has been made available for general use and is suitable for all production and development use cases.

Visit the PostgreSQL 12 release notes page to see all the new features and improvements in PostgreSQL 12 and to review the most significant updates. Let's jump right into installing PostgreSQL 12 on Ubuntu without further ado.

Step 1: Update System

If it's a fresh server instance, it's advised to upgrade your current system packages.
sudo apt update
sudo apt -y install vim bash-completion wget
sudo apt -y upgrade

After an upgrade, you must reboot.
sudo reboot

Step 2: Add PostgreSQL 12 Repository

We must add the PostgreSQL 12 repository to our Ubuntu computer and import the GPG key. To do this, enter the commands below.
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg

Add repository contents to your Ubuntu 22.04 system after importing the GPG key:
echo "deb http://apt.postgresql.org/pub/repos/apt/lsb_release -cs-pgdg main" |sudo tee /etc/apt/sources.list.d/pgdg.list

The newly added repository includes a variety of packages, including add-ons from third parties.

Step 3: Install PostgreSQL 12 on Ubuntu

Update the package list and install the PostgreSQL server and client packages on your Ubuntu 22.04 Linux system after successfully adding the repository.

sudo apt update
sudo apt -y install postgresql-12 postgresql-client-12

A message similar to the one seen in the following screenshot indicates that the installation was successful.

Image description

You can check PostgreSQL status using the following command:

systemctl status postgresql.service

To set come up after every system reboot using the following command:

systemctl status postgresql@12-main.service

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay