Unlock the Power of Databases: How to Install PostgreSQL Like a Pro

Introduction:

PostgreSQL is a powerful and popular open-source relational database management system. In this tutorial, we will walk you through how to Install PostgreSQL Ubuntu 22.04. By the end of this guide, you will have PostgreSQL up and running on your Ubuntu server.

PostgreSQL is a robust and feature-rich open-source database management system that is widely used by developers and organizations worldwide. If you’re running Ubuntu 22.04 and want to set up PostgreSQL, follow the step-by-step instructions below to get started.

Step 1: Update System Packages for Install PostgreSQL:

Before installing any new software, it’s always a good idea to update the system packages to their latest versions. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

Run the following command to add the PostgreSQL GPG key.

curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /usr/share/keyrings/postgresql-key.gpg >/dev/null

Add the APT repository to your sources list.

sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgresql-key.gpg arch=amd64] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Update the system repository.

 sudo apt update

Now, you can install PostgreSQL using the command below.

sudo apt install postgresql postgresql-contrib

The postgresql-contrib package contains some extra utilities.

Check the status of the PostgreSQL service.

sudo systemctl status postgresql

Install PostgreSQL - Postgresql Running Status

You can see that the service is enabled and running by default.

Launch the PostgreSQL shell.

sudo -i -u postgres psql

For more info please visit the official site – https://www.postgresql.org/docs/current/tutorial-install.html

Leave a Comment