Install PostgreSQL 13 on Fedora 33/32/31/30

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose

PostgreSQL is a powerful and 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 update, the latest version of the PostgreSQL database is 13. You can check the new features, improvements and bug fixes of PostgreSQL 13 on the official website. Release notes page.

Some changes were recorded in the PostgreSQL 13 version.

  • Improvements brought by deduplication of B-tree index entries-space saving and performance improvement
  • Queries that use aggregate tables or partitioned tables can improve performance.
  • Incremental sort
  • Better query plans when using extended statistics
  • Parallel cleaning of indexes

The PostgreSQL team provides pre-built binary packages for installing YUM-based and Debian-based Linux systems. Before installing PostgreSQL 13 on Fedora, we will add the required repositories.

Step 1: Update the system

Always work on the latest Fedora system.

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

Perform a reboot after a successful upgrade:

sudo reboot

Step 2: Add PostgreSQL Yum repository

Add the PostgreSQL Yum repository to your Fedora system by running the following command:

Fedora 33:

sudo dnf install

Fedora 32:

sudo dnf install

Fedora 31:

sudo dnf install

Fedora 30:

sudo dnf install

Fedora 29:

sudo dnf install

When prompted to confirm installation, press ÿ 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



Step 3: Install PostgreSQL 13 on Fedora 33/32/31/30

After adding the PostgreSQL repository to the Fedora system, install the PostgreSQL 13 Server / Client package:

sudo dnf install postgresql13-server postgresql13

Agree to the installation prompt you received.

Dependencies resolved.
 Package                                       Architecture                     Version                                    Repository                        Size
 postgresql13-server                           x86_64                           13.1-3PGDG.f33                             pgdg13                           5.8 M
Installing dependencies:
 libicu                                        x86_64                           67.1-4.fc33                                fedora                           9.7 M
 postgresql13                                  x86_64                           13.1-3PGDG.f33                             pgdg13                           1.4 M
 postgresql13-libs                             x86_64                           13.1-3PGDG.f33                             pgdg13                           789 k

Transaction Summary
Install  4 Packages

Total download size: 18 M
Installed size: 65 M
Is this ok [y/N]: y

This includes GPG key import:

Total                                                                                                                              13 MB/s |  18 MB     00:01
warning: /var/cache/dnf/pgdg13-5b69a3a370fb59a8/packages/postgresql13-13.1-3PGDG.f33.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
PostgreSQL 13 for Fedora 33 - x86_64                                                                                              1.6 MB/s | 1.7 kB     00:00
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <[email protected]>"
 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 4: Initialize the PostgreSQL database

Run the following command to initialize the database:

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

Start and enable the postgresql database service:

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

Confirm the 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 5: Enable remote access to PostgreSQL (optional)

For remote client connections, you may have to allow 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 the “listening address” to the server IP address or “*“” for all interfaces or specific IP addresses/subnets.

$ sudo vi /var/lib/pgsql/13/data/postgresql.conf 

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

After making the changes, restart the PostgreSQL 13 service.

sudo systemctl restart postgresql-13

Step 6: Set the password of the PostgreSQL administrator user

Set the PostgreSQL administrator user password.

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

where StrongDBPassword Is the new password of the postgres user.

Step 7: Install pgAdmin 4 Web Management

If you need an easy way to manage the PostgreSQL database server (similar to MySQL’s phpMyAdmin), please consider installing pgAdmin4.

Install pgAdmin 4 on Fedora

Enjoy the fun of running PostgreSQL 13 on Fedora 33/32/31/30 Linux systems.

Other guides on Fedora;

Configure Open vSwitch on Fedora

Install Zoom Client on Fedora

Install Brave Web Browser on Fedora

You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose