Install PostgreSQL 13 on Fedora 36/35/34/33/32/31

Posted on 267 views

PostgreSQL is a powerful, widely used relational database management system designed to be resilient and fault tolerant. The PostgreSQL database is based on POSTGRES 4.2. As of this article update the latest release of PostgreSQL database is 13. You can check the new features, improvements and bug fixes on PostgreSQL 13 in the official release notes page.

Some changes noted in PostgreSQL 13 release.

  • Improvements from de-duplication of B-tree index entries – Space savings and performance gains from
  • Queries that use aggregates or partitioned tables gets improved performance.
  • Incremental sorting
  • Better query planning when using extended statistics
  • Parallelized vacuuming of indexes

The PostgreSQL team provides pre-built binary packages for installation YUM based and Debian based Linux systems. We will add the required repositories before installing PostgreSQL 13 on Fedora 36/35/34/33/32/31.

Step 1 – Install PostgreSQL 13 on Fedora 36/35/34/33/32/31

Follow the steps in this section to install and configure PostgreSQL 13 on Fedora.

Update System

Always work on an up-to-date Fedora system.

sudo dnf update -y
sudo dnf install -y vim bash-completion wget

Perform a reboot after successful upgrade:

sudo reboot

Reset default AppStream modules for PostgreSQL.

sudo dnf module reset postgresql -y

Add the PostgreSQL Yum Repository

Add PostgreSQL Yum Repository to your Fedora system by running the below command:

Fedora 36:

sudo dnf install

Fedora 35:

sudo dnf install

Fedora 34:

sudo dnf install

Fedora 33:

sudo dnf install

Fedora 32:

sudo dnf install

Fedora 31:

sudo dnf install

When prompted to confirm installation, press the key.

Dependencies resolved.
 Package                                     Architecture                      Version                              Repository                               Size
 pgdg-fedora-repo                            noarch                            42.0-13                              @commandline                             10 k

Transaction Summary
Install  1 Package

Total size: 10 k
Installed size: 11 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                          1/1
  Installing       : pgdg-fedora-repo-42.0-13.noarch                                                                                                          1/1
  Verifying        : pgdg-fedora-repo-42.0-13.noarch                                                                                                          1/1



After the PostgreSQL Repository is added to Fedora system, install PostgreSQL 13 Server / Client packages:

sudo dnf install postgresql13-server postgresql13

Agree to the installation prompts that you receive.

Dependencies resolved.
 Package                                                Architecture                              Version                                             Repository                                 Size
 postgresql13-server                                    x86_64                                    13.7-1PGDG.f36                                      pgdg13                                    5.7 M
Installing dependencies:
 postgresql13                                           x86_64                                    13.7-1PGDG.f36                                      pgdg13                                    1.4 M
 postgresql13-libs                                      x86_64                                    13.7-1PGDG.f36                                      pgdg13                                    781 k

Transaction Summary
Install  3 Packages

Total download size: 7.9 M
Installed size: 32 M
Is this ok [y/N]: y

This includes GPG key importation:

Total                                                                                                                                                                  15 MB/s | 7.9 MB     00:00
PostgreSQL 13 for Fedora 36 - x86_64                                                                                                                                  1.6 MB/s | 1.7 kB     00:00
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project "
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Is this ok [y/N]: y

Step 2 – Initialize PostgreSQL database

Run the commands below to initialize the database:

$ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

Start and enable postgresql database service:

$ sudo systemctl enable --now postgresql-13
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/postgresql-13.service.

Confirm service status.

$ systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2021-02-08 21:25:49 UTC; 21s ago
    Process: 1076 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir $PGDATA (code=exited, status=0/SUCCESS)
   Main PID: 1081 (postmaster)
      Tasks: 8 (limit: 1125)
     Memory: 16.2M
        CPU: 59ms
     CGroup: /system.slice/postgresql-13.service
             ├─1081 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
             ├─1082 postgres: logger
             ├─1084 postgres: checkpointer
             ├─1085 postgres: background writer
             ├─1086 postgres: walwriter
             ├─1087 postgres: autovacuum launcher
             ├─1088 postgres: stats collector
             └─1089 postgres: logical replication launcher

Feb 08 21:25:49 fed33 systemd[1]: Starting PostgreSQL 13 database server...
Feb 08 21:25:49 fed33 postmaster[1081]: 2021-02-08 21:25:49.811 UTC [1081] LOG:  redirecting log output to logging collector process
Feb 08 21:25:49 fed33 postmaster[1081]: 2021-02-08 21:25:49.811 UTC [1081] HINT:  Future log output will appear in directory "log".
Feb 08 21:25:49 fed33 systemd[1]: Started PostgreSQL 13 database server.

Step 3 – Enable remote Access to PostgreSQL (Optional)

For remote clients connectivity you may have to permit access in the firewall.

sudo firewall-cmd --add-service=postgresql --permanent
sudo firewall-cmd --reload

Then edit the file /var/lib/pgsql/13/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces, or specific IP address/subnet.

$ sudo vi /var/lib/pgsql/13/data/postgresql.conf 
listen_addresses = '*'

Also set PostgreSQL to accept remote connections from allowed hosts.

$ sudo vim /var/lib/pgsql/11/data/pg_hba.conf
# Accept from anywhere
host all all md5

# Accept from trusted subnet
host all all md5

Restart PostgreSQL 13 service after making the change.

sudo systemctl restart postgresql-13

Step 4 – Set PostgreSQL admin user’s password

Set PostgreSQL admin user password.

sudo su - postgres
psql -c "alter user postgres with password 'StrongDBPassword'"

Where StrongDBPassword is the new password for postgres user.

Step 5 – Install pgAdmin 4 Web Management

If you need an easy way for managing PostgreSQL database server (Similar to phpMyAdmin for MySQL), consider installing pgAdmin4.

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.