FedoraRHEL Based

How To Install PostgreSQL on Fedora 39

Install PostgreSQL on Fedora 39

In this tutorial, we will show you how to install PostgreSQL on Fedora 39. PostgreSQL, often referred to as Postgres, is an open-source relational database management system (RDBMS). It’s known for its extensibility, adherence to SQL standards, and its support for various data types.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the PostgreSQL open-source relational database on a Fedora 39.


Before diving into the installation process, let’s ensure that you have everything you need:

  • A server running one of the following operating systems: Fedora 39.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You’ll need an active internet connection to download PostgreSQL and its dependencies.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install PostgreSQL on Fedora 39

Step 1. Before diving into installation, ensure your Fedora 39 system is up-to-date. Execute the following commands:

sudo dnf clean all
sudo dnf update

Step 2. Installing PostgreSQL on Fedora 39.

Adding the PostgreSQL repository is crucial for Fedora 39 users. Follow these steps:

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

This command installs the repository configuration package, essential for pulling PostgreSQL packages into your system.

Now that the repository is set up, it’s time to install PostgreSQL. Use dnf to install the PostgreSQL server and client packages:

sudo dnf install postgresql16-server

Following installation, initialize the PostgreSQL database:

sudo /usr/pgsql-16/bin/postgresql-16-setup initdb

Next, start and enable the PostgreSQL service:

sudo systemctl enable postgresql-16
sudo systemctl start postgresql-16

Step 3. Installation Setup.

Securing your PostgreSQL installation involves creating a superuser account and password. Access the PostgreSQL prompt:

sudo -i -u postgres

Inside the PostgreSQL prompt, create a new superuser:

CREATE ROLE your_user WITH SUPERUSER LOGIN PASSWORD 'your_strong_password';

Replace ‘your_user‘ and ‘your_password‘ with your desired username and password.

To ensure a successful installation, attempt to connect to the PostgreSQL server:

psql -U your_user -d postgres

Step 4. Configure Firewall.

Setting up the firewall for PostgreSQL on Fedora involves allowing traffic on the PostgreSQL port, typically 5432, while blocking unauthorized access. Here are the steps to configure the firewall:

sudo firewall-cmd --zone=public --add-port=5432/tcp --permanent

This command opens port 5432 for TCP traffic on the public zone. The --permanent flag makes the rule persistent across reboots.

Reload the firewall to apply the changes:

sudo firewall-cmd --reload

Check if the rule is added successfully:

sudo firewall-cmd --zone=public --list-ports

Congratulations! You have successfully installed PostgreSQL. Thanks for using this tutorial for installing the PostgreSQL database on your Fedora 39 system. For additional Apache or useful information, we recommend you check the official PostgreSQL website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button