Download and install PostgreSQL on CentOS 8 from the repository

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.

https://www.postgresql.org/download/

 

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

install_postgresql

 

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

install_postgresql

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.

install_postgresql

 

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

install_postgresql


 

2. Download Postgresql DBMS.

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

install_postgresql

2.2. Installing the repository.

$. sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

install_postgresql


 

3. Disabling unnecessary modules.

$. sudo dnf -qy module disable postgresql

install_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

install_postgresql


 

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

install_postgresql

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

install_postgresql


 

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 0.0.0.0/0 password

install_postgresql

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.

install_postgresql


 

7. Launching the database.

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

$. service postgresql-14 start

install_postgresql


 

8. Connecting to a database.

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

$. psql -U postgres

install_postgresql


 

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

SIMILAR ARTICLES

PostgreSQL - How to determine which files on disk correspond to tables in a database
PostgreSQL - How to determine which files on disk correspond to tables in a database
POSTGRESQL
Read more
PostgreSQL - How to find out the size of tables in a database
PostgreSQL - How to find out the size of tables in a database
POSTGRESQL
Read more
PostgreSQL - How to check user privileges
PostgreSQL - How to check user privileges
POSTGRESQL
Read more