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.
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
Top comments (0)