How to install PostgreSQL 15 and pgadmin on RHEL 9

In this article, we will show you How to install PostgreSQL 15 and pgadmin on RHEL 9.

PostgreSQL is a powerful, widely-used, open-source, multi-platform, and advanced object-relational database system known for its proven architecture, reliability, data integrity, robust feature set, and extensibility.

pgadmin is an advanced, open-source, full-featured, and web-based administration and management GUI(graphical user interface) tool for the PostgreSQL server.

Install PostgreSQL 15 on RHEL 9

1. First, we have to disable built-in PostgreSQL module by running following command.

dnf -qy module disable postgresql

If this throws error. No need to bother. Then, proceed to next step.

2. Now, enable the official PostgreSQL Yum Repository as shown below.

On RHEL9/Rocky Linux 9/Oracle Linux 9:

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

How to install PostgreSQL 15 and pgadmin on RHEL 9

On RHEL8/Rocky Linux 8/Oracle Linux 8:

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

3. Install PostgreSQL 15 on RHEL 9 by running below command.

sudo dnf install -y postgresql15-server postgresql-contrib

4. Once the installation is complete, initialize the PostgreSQL database, then start the PostgreSQL-15 service and enable it to automatically start at system boot. Then check if the service is up and running, and is enabled as shown below:

sudo /usr/pgsql-15/bin/postgresql-15-setup initdb

systemctl status postgresql-15

So, PostgreSQL service is not started and disabled to restart after operating system restarts.

Enable service using below command.

systemctl enable postgresql-15

Start PostgreSQL service using below command:

systemctl start postgresql-15

5. Set the password postgres user at System level(Linux terminal)

sudo passwd postgres

6. Now connect to PostgreSQL server using below commands:

sudo su - postgres psql

/

7. Now changes postgres super user password in PostgreSQL server.

alter user postgres with password 'admin@123';

Install pgadmin 4 on RHEL 9

1. Now we will install pgAdmin 4 to manage the PostgreSQL database from the web. First, you need to enable the EPEL and pgAdmin yum repositories which contain some of the dependencies.

sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm sudo dnf install -y https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-2-1.noarch.rpm

2. Now build a cache for newly installed pgAdmin and EPEL repositories and install pgAdmin using the below commands:

sudo dnf makecache

sudo yum install pgadmin4

3. Now, we have to start the httpd service, and enable auto start whenever Linux reboots.

sudo systemctl start httpd sudo systemctl status httpd sudo systemctl enable httd

4. Now, connect to PostgreSQL server from pgadmin4 on RHEL:

Click on Show applications in RHEL then search for pgadmin as shown below and click on pgadmin4:

Then provide password for pgadmin4.

5.Now right click on servers and select register and select Server. Then provide Server Name, PostgreSQL hostname/IP address, database name, user name and password for user and click on Save.

So in this article, we have seen how to install PostgreSQL 15 and pgadmin4 on RHEL 9 step by step.

For the same tutorial, go to below video: