Download and install PostgreSQL on CentOS 8 from the repository

  • Last update: Apr 3, 2024
  • Views: 46
  • Author: Admin
Download and install PostgreSQL on CentOS 8 from the repository

Colleagues hello to all.

PostgreSQL — this is a cool open source object-relational database system. PostgreSQL has been actively developed for over 30 years and has earned a reliable reputation and performance. In today's article we will talk about how to download and install the PostgreSQL DBMS from the repository on Centos 8.


Article content:

  1. Select the version of Postgresql DBMS to download.
  2. Download Postgresql DBMS.
  3. Disable unnecessary modules.
  4. Install Postgresql DBMS.
  5. Database initialization.
  6. Setting up authorization in the database.
  7. Starting the database.
  8. Database connection.


1. Selecting the version of Postgresql DBMS to download.

1.1. Go to the official Postgresql website.


1.2. We choose under which operating system we need packages. I choose Linux.



1.3. Next, you will need to choose distribution, since I have Centos 8 installed, I choose Red Hat.


1.4. After choosing the distribution kit, the next steps you need to choose which version of the DBMS you want to install. I choose what I want 14 version and system bitness x86_64.



1.5. After all the fields are filled in, you should appear instructions for installing the DBMS.



2. Download Postgresql DBMS.

2.1. Copy the link to the rpm package of the repository.


2.2. Installing the repository.

$. sudo dnf install -y



3. Disabling unnecessary modules.

$. sudo dnf -qy module disable postgresql



4. Install Postgresql DBMS.

After all that we have done, now we can install our Postgresql DBMS, for this we will use the command:

$. sudo dnf install -y postgresql14-server



5. Initializing the database.

After installing the Postgresql DBMS, we now need to create our database. To create a database, use the command:

$. sudo /usr/pgsql-14/bin/postgresql-14-setup initdb


By default, the database will be initialized in the  /var/lib/pgsql/14/data directory.



6. Configuring database authorization.

If you just start the database now, you won't be able to connect to it because you need to configure several parameters for authorization in the configuration files.

6.1. Edit the  pg_hba.conf file located in the  /var/lib/pgsql/14/data directory. Add to it:

local all all trust
host all all password


The first string of parameters means that any local server user will be able to connect to the database without entering a password. The second line of parameters means that any external client will be able to connect to the database only after entering the password.


6.2. Edit the postgresql.conf file located in the /var/lib/pgsql/14/data directory.

Search for the  listen_addresses parameter, and replace localhost with an asterisk. The asterisk will mean that not only local users of the server, but also external clients can connect to the database.



7. Launching the database.

We only need to start our database, for this we will use the command:

$. service postgresql-14 start



8. Connecting to a database.

To connect to a database in the Postgresql DBMS, there is a psql utility.

$. psql -U postgres



Thank you all, I hope that my article helped you in some way.