0% found this document useful (0 votes)
3 views

PostgreSQL Installation Using Yum_dnf

This document provides a step-by-step guide for installing PostgreSQL 16 on RHEL/CENTOS 9. It includes commands for disabling existing PostgreSQL modules, installing the server and contrib packages, initializing the database, and starting the PostgreSQL service. Additionally, it outlines how to connect to the database and check the list of databases after installation.

Uploaded by

D Pavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

PostgreSQL Installation Using Yum_dnf

This document provides a step-by-step guide for installing PostgreSQL 16 on RHEL/CENTOS 9. It includes commands for disabling existing PostgreSQL modules, installing the server and contrib packages, initializing the database, and starting the PostgreSQL service. Additionally, it outlines how to connect to the database and check the list of databases after installation.

Uploaded by

D Pavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

PostgreSQL 16 Installation – A Step-by-Step Guide

Steps to Install PostgreSQL on RHEL/CENTOS 9:

1) ps -ef | grep postgres


2) dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-
x86_64/pgdg-redhat-repo-latest.noarch.rpm
3) dnf -qy module disable postgresql
4) dnf install -y postgresql16-server
5) dnf install -y postgresql16-contrib
6) cd /usr/pgsql-16/bin/
7) /usr/pgsql-16/bin/postgresql-16-setup initdb
8) cd /var/lib/pgsql/16/data/
9) systemctl enable postgresql-16
10) systemctl start postgresql-16
11) systemctl status postgresql-16

➢ Before installing the PostgreSQL database, ensure no related processes are running.
• ps -ef | grep postgres

➢ Go to following website https://www.postgresql.org/download/linux/redhat/ and click


packages on left side -> click on Linux -> and choose you Linux distribution in my case
mine is REDHAT. After choosing all option as per your requirement, if you go little down,
and select here as per your requirement which Postgres database version want to install
and Linux distribution.
➢ Copy the provided script and paste it one by one into your server, as shown in the
screenshots below.
• dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-
x86_64/pgdg-redhat-repo-latest.noarch.rpm

➢ Disable the built-in PostgreSQL module


• dnf -qy module disable postgresql
➢ Install PostgreSQL:
• dnf install -y postgresql16-server
➢ After installing Postgres, it’s time to install contrib package
• dnf install -y postgresql16-contrib
➢ To check the utilities available in PostgreSQL, navigate to the bin directory using the
following command:
• cd /usr/pgsql-16/bin/

➢ It’s time to initialize the database


• /usr/pgsql-16/bin/postgresql-16-setup initdb
➢ To navigate to the PostgreSQL data directory, use the following command:
• cd /var/lib/pgsql/16/data/

➢ Now it’s time to enable and start service


• systemctl enable postgresql-16
• systemctl start postgresql-16
• systemctl status postgresql-16
➢ After installing Database, it’s time to connect database and check list of databases and
create sample database.
• su – postgres
• psql
• \l

You might also like