We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install PostgreSQL 11 on Fedora 38/37/36/35/34/33

Learn how to – Install PostgreSQL 11 on Fedora 38/37/36/35/34/33.

This guide is for installation of PostgreSQL 11 on Fedora 38/37/36/35/34/33/32. PostgreSQL is a powerful open source relational database system with a strong reputation for reliability, feature robustness, and performance.

Key PostgreSQL 11 Enhancements:

  • Improvements to partitioning functionality
  • SQL stored procedures that support embedded transactions
  • Improvements to parallelism
  • Window functions now support all framing options shown in the SQL:2011 standard
  • Optional Just-in-Time (JIT) compilation for some SQL code, speeding evaluation of expressions
  • Performance improvements, including the ability to avoid a table rewrite for ALTER TABLE … ADD COLUMN with a non-null column default
  • Covering indexes can now be created, using the INCLUDE clause of CREATE INDEX

Read more about PostgreSQL 11 new features on the Release page. Use the steps below to install PostgreSQL 11 on your Fedora system. For those new to Fedora, we have an installation guide:

The default version available on Fedora Repository and Modular Repository is 10.x. Check our guide to understand How to use Fedora Modular Repository

For CentOS 7, use: How to install PostgreSQL 11 on CentOS 7

Step 1: Update System

Ensure system packages are up to date:

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

Since you may have Kernel updates, it is recommended to reboot your system after an upgrade

sudo reboot

Step 2: Add the PostgreSQL Yum Repository

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

Fedora 37:

sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-37-x86_64/pgdg-fedora-repo-latest.noarch.rpm

Fedora 36:

sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-36-x86_64/pgdg-fedora-repo-latest.noarch.rpm

Fedora 35:

sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-35-x86_64/pgdg-fedora-repo-latest.noarch.rpm

Fedora 34:

sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-34-x86_64/pgdg-fedora-repo-latest.noarch.rpm

Fedora 33:

sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-33-x86_64/pgdg-fedora-repo-latest.noarch.rpm

Fedora 32:

sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/F-32-x86_64/pgdg-fedora-repo-latest.noarch.rpm

When prompted to confirm installation, press the key.

Dependencies resolved.
======================================================================================================================================================================================================
 Package                                              Architecture                               Version                                       Repository                                        Size
======================================================================================================================================================================================================
Installing:
 pgdg-fedora-repo                                     noarch                                     42.0-26                                       @commandline                                      10 k

Transaction Summary
======================================================================================================================================================================================================
Install  1 Package

Total size: 10 k
Installed size: 12 k
Is this ok [y/N]: y

Step 3: Install PostgreSQL Server and Client packages

After adding PostgreSQL Yum Repository, install PostgreSQL Server / Client packages:

sudo dnf install postgresql11-server postgresql11 -y

Confirm installation of packages.

....
Dependencies resolved.
======================================================================================================================================================================================================
 Package                                                Architecture                              Version                                             Repository                                 Size
======================================================================================================================================================================================================
Installing:
 postgresql11-server                                    x86_64                                    11.18-1PGDG.f37                                     pgdg11                                    5.1 M
Installing dependencies:
 postgresql11                                           x86_64                                    11.18-1PGDG.f37                                     pgdg11                                    1.7 M
 postgresql11-libs                                      x86_64                                    11.18-1PGDG.f37                                     pgdg11                                    734 k

Transaction Summary
======================================================================================================================================================================================================
Install  3 Packages

Total download size: 7.5 M
Installed size: 31 M
Is this ok [y/N]: y

Confirm the installed package:

$ rpm -qi postgresql11-server
Name        : postgresql11-server
Version     : 11.19
Release     : 1PGDG.f38
Architecture: x86_64
Install Date: Mon 24 Apr 2023 08:23:24 PM UTC
Group       : Unspecified
Size        : 21216487
License     : PostgreSQL
Signature   : DSA/SHA1, Thu 20 Apr 2023 07:25:09 PM UTC, Key ID 1f16d2e1442df0f8
Source RPM  : postgresql11-11.19-1PGDG.f38.src.rpm
Build Date  : Thu 20 Apr 2023 05:38:04 PM UTC
Build Host  : koji-fedora38-x86-64-pgbuild
Vendor      : PostgreSQL Global Development Group
URL         : https://www.postgresql.org/
...

Step 4: Initialize the database and enable automatic start

Now that the database packages have been installed, Initialize the database by running the following command

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

Then start and enable the service to start on boot

sudo systemctl enable --now postgresql-11

Confirm service status.

$ systemctl status postgresql-11
 postgresql-11.service - PostgreSQL 11 database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql-11.service; enabled; preset: disabled)
     Active: active (running) since Thu 2023-01-19 14:46:37 UTC; 1s ago
       Docs: https://www.postgresql.org/docs/11/static/
    Process: 2143 ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 2148 (postmaster)
      Tasks: 8 (limit: 4543)
     Memory: 15.8M
        CPU: 90ms
     CGroup: /system.slice/postgresql-11.service
             ├─2148 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data/
             ├─2149 "postgres: logger   "
             ├─2151 "postgres: checkpointer   "
             ├─2152 "postgres: background writer   "
             ├─2153 "postgres: walwriter   "
             ├─2154 "postgres: autovacuum launcher   "
             ├─2155 "postgres: stats collector   "
             └─2156 "postgres: logical replication launcher   "

Jan 19 14:46:37 fedora.mylab.io systemd[1]: Starting postgresql-11.service - PostgreSQL 11 database server...
Jan 19 14:46:37 fedora.mylab.io postmaster[2148]: 2023-01-19 14:46:37.339 UTC [2148] LOG:  listening on IPv6 address "::1", port 5432
Jan 19 14:46:37 fedora.mylab.io postmaster[2148]: 2023-01-19 14:46:37.339 UTC [2148] LOG:  listening on IPv4 address "127.0.0.1", port 5432
Jan 19 14:46:37 fedora.mylab.io postmaster[2148]: 2023-01-19 14:46:37.342 UTC [2148] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Jan 19 14:46:37 fedora.mylab.io postmaster[2148]: 2023-01-19 14:46:37.344 UTC [2148] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
Jan 19 14:46:37 fedora.mylab.io postmaster[2148]: 2023-01-19 14:46:37.374 UTC [2148] LOG:  redirecting log output to logging collector process
Jan 19 14:46:37 fedora.mylab.io postmaster[2148]: 2023-01-19 14:46:37.374 UTC [2148] HINT:  Future log output will appear in directory "log".
Jan 19 14:46:37 fedora.mylab.io systemd[1]: Started postgresql-11.service - PostgreSQL 11 database server.

PostgreSQL 11 config file is/var/lib/pgsql/11/data/postgresql.conf

If you have a running Firewall service and remote clients should connect to your database server, allow PostgreSQL service.

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

Step 5: Enable remote Access to PostgreSQL

Edit the file /var/lib/pgsql/11/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces.

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

Also set PostgreSQL to accept remote connections

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

# Accept from trusted subnet
host all all 192.168.18.0/24 md5

Restart service

sudo systemctl restart postgresql-11

Step 6: Set PostgreSQL admin user’s password

Set PostgreSQL admin user

$ sudo su - postgres 
[postgres@fed ~]$ psql -c "alter user postgres with password 'StrongPassword'" 
ALTER ROLE

Create a test user and database

[postgres@fed ~]$ createuser test_user
[postgres@fed ~]$ createdb test_db -O test_user
[postgres@fed ~]$ grant all privileges on database test_db to test_user;

Login as a test_user  user try to create a table on the Database.

$ psql -U test_user -h localhost -d test_db

Step 7: Install pgAdmin 4 on Fedora

Install pgAdmin 4 on Fedora to administer your PostgreSQL from a web interface.

Also read:

Cart

Your Cart is Empty

Back To Shop