NEW LOCATION

Olá Brazil Brazil NVMe-powered VPS Plans in Brazil Now Available.

Deploy Instantly
  • +357 2425 0808
  • Login
  • English

Home

Blog

How to Install PostgreSQL on AlmaLinux 9...

How to Install PostgreSQL on AlmaLinux 9 Server

How to Install PostgreSQL on AlmaLinux 9 Server

NetShop ISP

NetShop ISP · Blog Author

Dec 12, 2022 · Technical Tutorials

PostgreSQL is a object-relational, open source database system that can be used for both small and large-scale projects; from simple websites and intranet applications to complex, ‘big data’ projects.

When a new server is installed, PostgreSQL’ s settings are very minimum as they are designed to run on the least amount of hardware possible.

In a survey conducted by Statista in August 2022, PostgreSQL is ranking second (just behind MySQL), in terms of the most used database technologies available. The main reason for PostgreSQL’s popularity, in addition to being open source, is the fact that it requires very minimum requirements on the hardware it will be installed at.

In this tutorial we will guide you through the simple steps of installing PostgreSQL on AlmaLinux 9 Operating system.

Install PostgreSQL on AlmaLinux 9

Before going through the rest of the article on how to install PostgreSQL on AlmaLinux 9 Server, please make sure you check the pre-requisites.

Pre-requisites

  1. VPS or Dedicated Server with AlmaLinux 9 Operating System
  2. Access on the server with a root or sudo privileges user

Step 1 – Update AlmaLinux 9 Server

Once you have access your newly installed AlmaLinux 9 server, update the packages to the latest versions available by executing the following command:

root@almalinux-server:~$ dnf update && dnf upgrade -y

Step 2 – Install PostgreSQL

At the time of writing this article (December 2022) the latest stable PostgreSQL version is 15.0. This version is not available, yet, in the default repo of AlmaLinux 9, so type the following command to install the official PostgreSQL repository in our system:

root@almalinux-server:~$ dnf install -y sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Then, update the index of your server’s packages with the following command:

root@almalinux-server:~$ dnf update -y

Now, you can install the PostgreSQL server with the following command:

root@almalinux-server:~$ dnf install postgresql15 postgresql15-server

As soon as the installation completes, execute the following command to initialize the newly installed database:

root@almalinux-server:~$ /usr/pgsql-15/bin/postgresql-15-setup initdb

Sample Output:

Initializing database … OK

Once database has been initialized, enter the following commands to start the PostgreSQL service and automatically enable it on startup:

root@almalinux-server:~$ systemctl start postgresql-15 && systemctl enable postgresql-15

To verify that the service has been started without errors, enter the following command:

root@almalinux-server:~$ systemctl status postgresql-15

Sample Output:

postgresql-15.service – PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2022-12-02 21:03:15 CEST; 1min 25s ago
Docs: https://www.postgresql.org/docs/15/static/

Step 3 – Set or Change the PostgreSQL User Password

Upon successful installation and first startup of the PostgreSQL database service, you can change the default user password for PostgreSQL as follows:

root@almalinux-server:~$ passwd postgres

You will be prompted to set a new password and then to re-type it.

Sample Output:

Changing password for user postgres.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Step 4 (optional) – Allow Remote Access to PostgreSQL Database

By default, PostgreSQL is configured to listen to local connections only.

If you need to access the database remotely (e.g. from your computer or from a software in another server) then do the following:

  • Open the file /var/lib/pgsql/15/data/postgresql.conf
  • Replace the line listen_addresses = ‘localhost with listen_addresses = ‘*
  • Open the file /var/lib/pgsql/15/data/pg_hba.conf
  • Add this entry at the end of the file: host all all 0.0.0.0/0 md5
  • Save and close the file

For the changes to take effect restart the PostgreSQL service as follows:

root@almalinux-server:~$ systemctl restart postgresql-15

This is it! You have successfully installed PostgreSQL 15 on AlmaLinux 9 Server. Enjoy!

Press Releases
79

Free VPS Trial

No Credit Card Required.

Recent Posts

Black Friday & Cyber Monday Offer – 30% Lifetime Discount on VPS Plans

Black Friday & Cyber Monday Offer – 30% Lifetime Discount on VPS Plans

02 December, 2024

How To Install Sendy on Ubuntu 22.04 Server

How To Install Sendy on Ubuntu 22.04 Server

27 November, 2024

How To Extract Certificates and Private Key from .PFX file

How To Extract Certificates and Private Key from .PFX file

19 November, 2024

NetShop ISP CEO Stefano Sordini to Moderate Key Panel on Forex AI Automation at Cyprus Fintech Summit 2024

NetShop ISP CEO Stefano Sordini to Moderate Key Panel on Forex AI Automation at Cyprus Fintech Summit 2024

15 November, 2024

Preparing for the Daylight Saving Time (DST) Change: Essential Updates for MetaTrader 4/5 Platforms

Preparing for the Daylight Saving Time (DST) Change: Essential Updates for MetaTrader 4/5 Platforms

25 October, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer