Home  »  ArticlesGuidesHardwareHow ToLibrariesProgrammingTechnology   »   How to Install PostgreSQL (psql) on AlmaLinux 8.10 Systems

How to Install PostgreSQL (psql) on AlmaLinux 8.10 Systems

PostgreSQL, commonly referred to as psql, is a powerful open-source relational database system known for its reliability and robust feature set. If you’re using AlmaLinux 8.10 and need to set up PostgreSQL for your projects or applications, this guide will walk you through the installation process step-by-step.

Step 1: Update System Packages

Before installing any new software, it’s always a good practice to update your system’s package repository and installed packages to their latest versions. Open a terminal and execute the following commands:

$ sudo dnf clean all
$ sudo dnf update

This ensures that you have the latest versions of packages and fixes any potential dependency issues.

Step 2: Install PostgreSQL Server

AlmaLinux uses the DNF package manager for package installations. PostgreSQL packages are available in the default repositories, so you can install them using the following command:

$ sudo dnf install postgresql-server

During the installation process, you might be prompted to confirm the installation by typing y and then pressing Enter.

Step 3: Initialize the Database

Once PostgreSQL is installed, you need to initialize the database before starting the service. Run the following command:

$ sudo postgresql-setup --initdb

This command initializes a new PostgreSQL database cluster and sets up the necessary configuration files.

Step 4: Start and Enable PostgreSQL Service

After initializing the database, you can start the PostgreSQL service and enable it to start automatically at boot time with the following commands:

$ sudo systemctl start postgresql
$ sudo systemctl enable postgresql

To verify that PostgreSQL is running, you can use the systemctl command to check its status:

$ sudo systemctl status postgresql

If PostgreSQL has started successfully, you should see an output indicating that the service is active and running.

Step 5: Access PostgreSQL Prompt (psql)

To interact with PostgreSQL, you can use the psql command-line interface. By default, PostgreSQL creates a user named postgres with administrative privileges. Switch to this user and access the psql prompt:

$ sudo su - postgres
$ psql

You should now be logged into the PostgreSQL interactive terminal (psql), where you can start executing SQL commands and managing your databases.

Step 6: Set a Password for the PostgreSQL User

By default, the postgres user does not have a password set. To secure your PostgreSQL installation, set a password for this user using the following command inside the psql prompt:

$ \password postgres

Enter a strong password and confirm it when prompted. This password will be required whenever you log in as the postgres user.


Congratulations! You’ve successfully installed PostgreSQL on your AlmaLinux 8.10 system. You can now start creating databases, defining schemas, and utilizing the full power of PostgreSQL for your applications. Remember to secure your database by configuring firewall rules and following best practices for database administration.

If you encounter any issues or have specific requirements, refer to the PostgreSQL documentation for detailed guidance. PostgreSQL’s extensive documentation covers everything from basic installation to advanced configurations and optimizations.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.