PostgreSQL referred to in some sources as Postgres, is one of the most powerful open-source databases in the world. This database emphasizes flexibility and compliance with standards. PostgreSQL is developed by the PostgreSQL Global Development Team, which includes a large number of volunteers. Postgres Database is an object-relational database management system that is optimized for different types of operating systems. It can also be installed and serviced on various models of operating systems such as Windows, Linux, and macOS. In this article, we are going to teach you How to Install PostgreSQL on AlmaLinux 8.4. You can visit the packages available in Eldernode to purchase a Linux VPS server.
Table of Contents
How to Install PostgreSQL on AlmaLinux 8.4
What is PostgreSQL and its Features?
PostgreSQL is a database management system that easily shares its popularity with the MySQL database. This DBMS is considering as an object-relational database management system in which user-defined objects and table approaches are combining to build more complex data structures. One of its goals is to strengthen compliance and development standards. This DBMS is developing by PostgreSQL Global Development Group and is the only one in this group and has open-source capabilities. This database management system is mostly using in Microsoft, iOS, Android, and other platform systems.
PostgreSQL has the following features:
1. Design: PostgreSQL design is integrated, but Mysql design is in two layers (the first layer is the SQL layer and the second layer is the storage engine).
2. Speed: One of the commonalities in PostgreSQL and Mysql is speed. How to improve the speed of the two differs due to their different algorithms.
3. Ease of use: Easy to use PostgreSQL for professional users and easy-to-use Mysql for ordinary users.
4. Reliability: PostgreSQL is more secure than Mysql using the ACID structure.
Prerequisites to Install PostgreSQL on AlmaLinux 8.4
The first step in installing PostgreSQL is to add the PostgreSQL Repository using the following command. Note that the default version of PostgreSQL is in App stream PostgreSQL 10 repositories:
sudo dnf module list postgresql
In the next step to install the latest version of PostgreSQL, you need to install the PostgreSQL YUM repository using the following command:
sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Install PostgreSQL on AlmaLinux 8.4
After you have installed the necessary prerequisites in the previous section, we now want to install PostgreSQL on AlmaLinux 8.4. To do this, just follow the steps below. First, update the Rocky Linux repositories using the following command:
sudo dnf update
You should now disable the default module using the following command:
sudo dnf -qy module disable postgresql
Next, you need to install PostgreSQL 13 client and server by running the following command:
sudo dnf install postgresql13 postgresql13-server
Note: You need to type “y” and press ENTER every time you are asked to enter the GPG key.
Finally, you can verify PostgreSQL status by running the following command:
psql -V
How to Start PostgreSQL on AlmaLinux 8.4
In the previous section, we showed you how to install PostgreSQL. Now we want to teach you how to set up and start PostgreSQL. The first step is to enable PostgreSQL using the following command:
sudo systemctl enable postgresql-13
In the next step you can start PostgreSQL using the following command:
sudo systemctl start postgresql-13
You can now verify that PostgreSQL is running using the following command:
sudo systemctl status postgresql-13
You can use the following command to initialize the database:
sudo /usr/pgsql-*/bin/postgresql-*-setup initdb
Note that in the next step you need to create a password for the Postgres user. So you can enter the PostgreSQL shell by switching to the Postgres user:
sudo su - postgres
You can now access the database prompt with the following command:
psql
To secure a Postgres user using a password, you need to run the following command as a sudo user:
sudo passwd postgres
You can now enter and confirm a new password. In the next step, you must log in again as a Postgres user using the following command:
su - postgres
Finally, run the following command and enter your desired password instead of “your-password“:
psql -c "ALTER USER postgres WITH PASSWORD 'your-password';"
From now on, if you want to log in, you have to authenticate:
su - postgres
Conclusion
Due to the fact that the PostgreSQL database is open source, it adds a lot of functions, data types, and operators, which makes working with this database very simple. In this article, we tried to teach you How to Install PostgreSQL on AlmaLinux 8.4.