A Complete Tutorial to Install PostgreSQL Server on Fedora 31

PostgreSQL has been a crucial part of my work. I have been using this software for the last few years and personally I am pretty satisfied. In this article, I am going to share with you how to install PostgreSQL Server on Fedora 31. Fedora 31 is a great Linux distribution. It is very fast, lightweight and easy to use. I will try to give a complete step by step how to get PostgreSQL up and running on Fedora 31.

Steps to Install PostgreSQL Server on Fedora 31

Step 1. Update Fedora

The first thing to do is to update the system. Use the following command to update Fedora 31.

In some cases, you may need to reboot your system to complete the update process.

Step 2. Configure the PostgreSQL Repository on Fedora 31

Now we are going to add the PostgreSQL repository for Fedora 31. Paste the following command in Terminal

Press y to confirm the installation.

So at this point, we have successfully added the repository for PostgreSQL on Fedora 31. Now continue to the next step

Step 3. Install PostgreSQL Server

Now we are ready to install the PostgreSQL Server in our system. Use the following command:

The latest version of PostgreSQL 12 is available when this article is written.

Again, you will need to confirm the installation. Wait until the installation process completes.

Step 4. Initialize PostgreSQL Database

Now we continue the process of the database initialization and automatic start service. First, let’s initialize the database using this command.

Make sure you see the following result

Now start the PostgreSQL Service and enable the automatic start during boot

Output:

Check the service status

Output

Configure PostgreSQL through firewall

If you have the firewall enabled, you must allow PostgreSQL service through the firewall.

Step 5. Enable Remote Access to PostgreSQL Server

Well, I am pretty sure that you want your server is accessible from the network. This section will guide you how to enable remote access to PostgreSQL Server.

First, we need to edit the configuration file called postgresql.conf. This file is located under /var/lib/pgsql/12/data/ directory.

Now, find the following section in the configuration file:

And then, change it into this one

Then, we need to edit the pg_hba.conf file.

sudo nano /var/lib/pgsql/12/data/pg_hba.conf. Add the following line to the end of the file.

The line above will allow PostgreSQL Server to be accessed from anywhere, even from the internet.

Finally, restart the service

Step 6. Change the PostgreSQL admin password

We need to switch to postgres user first

sudo su – postgres

And then execute this command

Change the StrongPassword with your new password and you are set.

Admin

Leave a Reply

Your email address will not be published. Required fields are marked *