PostgreSQL Database Installation on Ubuntu 22.04 Using RPM

Introduction

PostgreSQL, also known as Postgres, is a powerful, open-source object-relational database system. It is widely used for its robustness, extensibility, and SQL compliance. This guide will walk you through the process of installing PostgreSQL on Ubuntu 22.04 using RPM, ensuring that your database is set up correctly and ready for use.

Summary of Steps:

Prerequisites

Before you begin, make sure you have the following prerequisites in place:

  • A running instance of Ubuntu 22.04.
  • Root or sudo access to your Ubuntu system.
  • Basic knowledge of command-line operations.

Step 1: Update Your System

It’s always a good practice to start by updating your system to ensure that all existing packages are up to date. Open your terminal and run the following command:

This command will update the package list and upgrade all installed packages to their latest versions.

Step 2: Install Required Dependencies

To install PostgreSQL using RPM, you need to have certain dependencies installed on your system. Use the following command to install these dependencies:

Step 3: Add PostgreSQL RPM Repository

Next, you need to add the PostgreSQL RPM repository to your system. This repository contains the necessary packages for PostgreSQL installation. Run the following commands:

Then, add the PostgreSQL repository to your sources list:

This command adds the PostgreSQL Global Development Group (PGDG) repository to your sources list.

Step 4: Update Package List

After adding the PostgreSQL repository, update your package list again to include the new PostgreSQL packages:

Step 5: Install PostgreSQL

Now, you can install PostgreSQL by running the following command:

This command installs PostgreSQL version 14, which is the latest version available at the time of writing.

Step 6: Verify Installation

Once the installation is complete, verify that PostgreSQL is installed and running. Use the following command to check the status of the PostgreSQL service:

You should see output indicating that the PostgreSQL service is active and running.

Step 7: Configure PostgreSQL

After installing PostgreSQL, you may need to perform some basic configuration. By default, PostgreSQL creates a new system user called postgres that you can use to access the database. Switch to this user and access the PostgreSQL prompt:

You can exit the PostgreSQL prompt by typing:

Step 8: Secure PostgreSQL

It’s essential to secure your PostgreSQL installation. Start by setting a password for the postgres user:

Basic Secure Step 1 : Login to Postgres user as a Sudo.
Basic Secure Step 2: Login to PostgreSQL by using psql Command
Basic Secure Step 3: Change the password for PostgreSQL User.

Sample Log:

Conclusion

You have successfully installed PostgreSQL on Ubuntu 22.04 using RPM. Your PostgreSQL database is now ready for use. You can start creating databases, tables, and other database objects to manage your data efficiently. For more advanced configuration and optimization, refer to the official PostgreSQL documentation.

 

Leave a Reply

Your email address will not be published. Required fields are marked *