How to install PostgreSQL 14 in Rocky Linux 8
Tags: postgres, linux, rockylinux, tutorial
Published: 2023-07-12 16:37:55

PostgreSQL is a free and open-source, highly stable relational database management system. It is backed by more than 20 years of community support, which is why it is used as the primary data store for many web, mobile, geospatial, and analytics applications.
Postgres 14 has a number of features that set it apart from its previous versions. Its major upgrade over the previous versions have been its ability to help application developers by managing workloads at scale and enhancing observability. It also has some additional security enhancements.

**Prerequisites:**
DNF package manager

The following are the steps you need to follow in order to install PostgreSQL 14 on your Rocky Linux:

**1. Update the packages list**
DNF is a software package manager that installs, updates, and removes packages. You should first run the following command in your terminal to upgrade your system to the current release:
`dnf update -y`

**2. Get the Postgres 14 repository**
Run the following command in your terminal to get Postgres from the Postgres website:
`dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm`

**3. Disable the default PostgreSQL repository**
By default, your system will have an older version of Postgres installed and configured. You need to disable that version by running the following command in your terminal:
`dnf -qy module disable postgresql`

**4. Install Postgres 14**
Now, you need to install the downloaded version of Postgres by running the following command in your terminal:
`dnf install postgresql14 postgresql14-server -y`

**5. Verify the installation**
Now that postgres is installed, you need to verify that the installation is successful by running the following command:
`systemctl status postgresql-14`
The following is the output you should get, that confirms successful installation:

```
● postgresql-14.service - PostgreSQL 14 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-02-16 16:47:32 UTC; 10s ago
     Docs: https://www.postgresql.org/docs/14/static/
  Process: 8423 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 8428 (postmaster)
    Tasks: 8 (limit: 11412)
   Memory: 17.4M
   CGroup: /system.slice/postgresql-14.service
           ├─8428 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
           ├─8430 postgres: logger 
           ├─8432 postgres: checkpointer 
           ├─8433 postgres: background writer 
           ├─8434 postgres: walwriter 
           ├─8435 postgres: autovacuum launcher 
           ├─8436 postgres: stats collector 
           └─8437 postgres: logical replication launcher 


Feb 16 16:47:32 linux systemd[1]: Starting PostgreSQL 14 database server...
Feb 16 16:47:32 linux postmaster[8428]: 2022-02-16 16:47:32.115 UTC [8428] LOG:  redirecting log output to logging collector process
Feb 16 16:47:32 linux postmaster[8428]: 2022-02-16 16:47:32.115 UTC [8428] HINT:  Future log output will appear in directory "log".
Feb 16 16:47:32 linux systemd[1]: Started PostgreSQL 14 database server.
```