PostgreSQL is a strong, extremely scalable, open supply, and cross-platform object-relational database system that runs on Unix-like working programs together with Linux and Home windows OS. It’s an enterprise-level database system that’s extremely dependable and gives knowledge integrity and correctness to customers.
On this article, we are going to clarify how one can set up the newest model of PostgreSQL 16 on RHEL and RHEL-based distributions akin to Rocky Linux, AlmaLinux, Oracle Linux, and Fedora utilizing the official PostgreSQL Yum repository.
1. Replace Software program Package deal
Earlier than initiating the PostgreSQL set up course of, ensure that to replace your Linux system software program packages by working the next dnf command.
sudo dnf replace
2. Enabling PostgreSQL Repository
Whereas PostgreSQL is accessible within the default system repositories, it’s advisable to allow the official PostgreSQL repository for entry to the newest model.
On RHEL, Rocky, AlmaLinux, and Oracle Linux 9:
sudo dnf set up -y https://obtain.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
On RHEL, Rocky, AlmaLinux, and Oracle Linux 8:
sudo dnf set up -y https://obtain.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
On Fedora 39:
sudo dnf set up -y https://obtain.postgresql.org/pub/repos/yum/reporpms/F-39-x86_64/pgdg-fedora-repo-latest.noarch.rpm
On Fedora 38:
sudo dnf set up -y https://obtain.postgresql.org/pub/repos/yum/reporpms/F-38-x86_64/pgdg-fedora-repo-latest.noarch.rpm
3. Putting in PostgreSQL 16 Server
After including the PostgreSQL repository in your respective Linux distribution, use the next command to put in the PostgreSQL server and consumer packages.
sudo dnf set up -y postgresql16-server postgresql16
Essential: PostgreSQL knowledge listing /var/lib/pgsql/16/knowledge/ incorporates all the knowledge information for the database.
4. Initializing PostgreSQL Database
Due to sure insurance policies relevant to Pink Hat-based distributions, the PostgreSQL set up won’t mechanically begin or have the database initialized as a part of the automated startup course of.
To finish your database set up, you want to initialize your database earlier than utilizing it for the primary time.
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
5. Configuring PostgreSQL for Distant Entry
To allow distant connections, you want to modify the configuration file postgresql.conf utilizing a textual content editor.
sudo vi /var/lib/pgsql/16/knowledge/postgresql.conf
Replace the listen_addresses parameter to permit connections from all hosts in your native community.
listen_addresses=”*”
After making the modifications to the configuration file, you want to restart the PostgreSQL service to use the brand new settings and allow computerized begin.
sudo systemctl restart postgresql-16
sudo systemctl allow postgresql-16
6. Setting PostgreSQL Person Password
Set the password for the default PostgreSQL consumer (postgres).
sudo passwd postgres
7. Accessing PostgreSQL Database
After setting the consumer password, you may entry the PostgreSQL database server utilizing the psql command.
sudo -i -u postgres
psql
Conclusion
Congratulations! You’ve efficiently put in PostgreSQL 16 on RedHat-based distributions (the newest model out there on the time). Keep in mind to seek the advice of the official PostgreSQL documentation for any version-specific particulars or modifications.