Home AlmaLinux How to Install PostgreSQL 14 in Rocky Linux and AlmaLinux

How to Install PostgreSQL 14 in Rocky Linux and AlmaLinux

Dependability and resilience are some of the key attributes that define PostgreSQL as the go-to Relational Database Management System (RDBMS) for both web-based and desktop-based software application projects.

Also, since PostgreSQL continues to find shelter under the umbrella of its global developer community, bugs and user issues related to database software’s life cycle are easily fixed thanks to its open-source status.

Therefore, PostgreSQL is a brand name in numerous enterprises invested in e-commerce platforms, financial transactions, and web traffic statistics. Also, the open-source nature of PostgreSQL embraces the addition of several programming languages’ functions to make its usability dynamic. These programming languages include the likes C/C++, Python, and Java.

The launch of PostgreSQL 14 displays outstanding speed enhancements. Therefore, constructing data-driven applications is no longer a hurdle for developers and administrators. Its improved performance relates to enhanced connection concurrency, query parallelism, logical replication, and high-write workloads.

Before we jump into the guided steps that will take us through the installation of PostgreSQL 14 on Rocky Linux and AlmaLinux, make sure you have root user privileges or you are a Sudoer user on your system.

Install PostgreSQL in Rocky Linux and AlamaLinux

Proceed to update your system to fix/apply the needed security patches responsible for its performance.

$ sudo dnf update

Next, list the default PostgreSQL repository module.

$ dnf module list postgresql 
List PostgreSQL Repo Module
List PostgreSQL Repo Module

The above output confirms that the system’s AppStream only accommodates PostgreSQL 9.6, 10, 12, and 13.

However, we are interested in PostgreSQL 14, so you need to install its official repository for your Rocky Linux/AlmaLinux system with the following command.

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

With the new repository for PostgreSQL 14 installed on our system, we need to get rid of the default PostgreSQL module by disabling it with the following command:

$ sudo dnf -qy module disable postgresql 
Disable PostgreSQL Module
Disable PostgreSQL Module

Afterward, proceed to install the Client and Server package for PostgreSQL 14 with the following command:

$ sudo dnf install -y postgresql14-server 
Install PostgreSQL in Rocky Linux
Install PostgreSQL in Rocky Linux

Initialize PostgreSQL Database Server

To initialize PostgreSQL 14, execute the following command, which will create PostgreSQL’s main configuration file.

$ sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
Initialize PostgreSQL Database
Initialize PostgreSQL Database

Next, start PostgreSQL with the following command:

$ sudo systemctl start postgresql-14

Finally, we need to enable PostgreSQL 14. This way, even when your system restarts, it will keep on executing without having to manually launch it.

$ sudo systemctl enable postgresql-14

Now check on the status of your PostgreSQL 14 installation to make sure it is running.

$ sudo systemctl status postgresql-14
Check PostgreSQL Status
Check PostgreSQL Status

Testing PostgreSQL Database Connection

Use the following command to connect to the PostgreSQL database.

$ sudo -u postgres psql
Connect PostgreSQL Database
Connect PostgreSQL Database

From here, you can secure your PostgreSQL 14 user (postgres) with a password via the command:

$ sudo passwd postgres
Create PostgreSQL Password
Create PostgreSQL Password

Afterward, you can re-login to the PostgreSQL shell and execute the needed database queries to propagate your data-driven projects.

PostgreSQL 14 is an improvement from its previous versions thanks to the new and improved features it brings to the table. Your Rocky Linux and AlmaLinux systems are now ready for your next big database project.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.