Share your love
Install PostgreSQL 15 on AlmaLinux 9 – Full and Easy Setup
This guide intends to teach you How To Install PostgreSQL 15 on AlmaLinux 9. The PostgreSQL Global Development Group announced on October 13 the release of PostgreSQL 15, it builds on the performance improvements of recent versions with notable gains for managing workloads in local and distributed deployments, including improved sorting.
This release improves the developer experience by adding the famous MERGE command and more capabilities to observe the state of the database.
You can now proceed to the following steps provided by the Orcacore website to Install PostgreSQL 15 on AlmaLinux 9.
Table of Contents
Steps To Install and Configure PostgreSQL 15 on AlmaLinux 9
To install PostgreSQL 15 on AlmaLinux 9, you must log in to your server as a non-root user with sudo privileges. To do this, follow our guide the Initial Server Setup with AlmaLinux 9.
Now follow the steps below to Install PostgreSQL 15 on AlmaLinux 9.
Step 1 – Set up PostgreSQL 15 on AlmaLinux 9
To Install PostgreSQL 15 on AlmaLinux 9, you must add the PostgreSQL 15 repository on your server.
Add PostgreSQL 15 Repository on AlmaLinux 9
At this point, you can use the command below to add the latest PostgreSQL repository on your server:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Then, update your local package index with the following command:
sudo dnf update -y
Install PostgreSQL 15 on AlmaLinux 9
First, you need to disable the default module of PostgreSQL with the following command:
sudo dnf -qy module disable postgresql
Then, use the following command to install PostgreSQL 15 on ALmaLinux 9:
sudo dnf install -y postgresql15-server
when your installation is completed, verify it by checking its version:
psql -V
In your output you will see:
Output
psql (PostgreSQL) 15.0
Initialize PostgreSQL 15 Database
At this point, you need to initialize the initdb database which is responsible for creating a new PostgreSQL cluster. A cluster is a group or collection of several databases that are managed by a cluster.
To do this, run the following command:
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
When it is finished, you will get the following output:
Output
Initializing database ... OK
Step 2 – Manage PostgreSQL 15 Server
At this step of install PostgreSQL 15 on AlmaLinux 9, you can start and enable your PostgreSQL 15. To do this, run the commands below:
# sudo systemctl enable postgresql-15
# sudo systemctl start postgresql-15
Verify your PostgreSQL 15 is active and running on your server with the command below:
sudo systemctl status postgresql-15
Output
● postgresql-15.service - PostgreSQL 15 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; ve>
Active: active (running) since Sat 2022-11-05 03:56:19 EDT; 8s ago
Docs: https://www.postgresql.org/docs/15/static/
Process: 34649 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir ${>
Main PID: 34654 (postmaster)
Tasks: 7 (limit: 23609)
Memory: 17.6M
CPU: 72ms
...
Step 3 – Configure PostgreSQL 15 on AlmaLinux 9
At this step, you have learned to Install PostgreSQL 15 on AlmaLinux 9. Now you can start to configure it. PostgreSQL uses a concept called roles to handle authentication and authorization.
During the PostgreSQL installation, Postgres is set up to use ident authentication, meaning that it associates Postgres roles with a matching Unix/Linux system account.
If a role exists within Postgres, a Unix/Linux username with the same name can sign in as that role.
One way is to switch over to the Postgres account on your server by running the following command:
sudo -i -u postgres
Output
postgres@sam:~$
You can access the Postgres 15 shell on AlmaLinux 9 by running the following command:
postgres@sam:~$ psql
With this command, you will see that your shell prompt changes to:
Output
psql (15.0)
Type "help" for help.
postgres=#
To exit from the PostgreSQL 15 shell on AlmaLinux 9, run the following command:
postgres=# \q
With this command, you will be back to the Postgres Linux command prompt.
postgres@sam:~$
You can type exit to return to the regular system user.
postgres@sam:~$ exit
Also, you can connect to your Postgres shell on AlmaLinux 9 in another way by typing the following command:
sudo -u postgres psql
In this way, you will directly connect to your PostgreSQL 15 shell.
Output
psql (15.0)
Type "help" for help.
postgres=#
Create a new PostgreSQL 15 Role
At this point, you can create a new Postgres role in two ways.
First, if you are logged in as a Postgres account, you can use the following command:
postgres@sam:~$ createuser --interactive
Second, you can use sudo for each command without switching from your normal account on AlmaLinux 9:
sudo -u postgres createuser --interactive
Both ways will be asked to enter your role name and whether the new role is a superuser or not.
Output
Enter name of role to add: orca
Shall the new role be a superuser? (y/n) y
Create a new PostgreSQL 15 Database
The Postgres authentication system for any role used to log in, the role should have a database with the same name that it can access.
If you logged in as the Postgres account, run the following command to create the database with the name of the role you have created in the previous step:
postgres@sam:~$ createdb orca
Or you can use sudo to create the database on AlmaLinux 9:
sudo -u postgres createdb orca
Open the Postgres 15 Shell with the new Role
At this point, you need to create a Linux user with the same name as your Postgres role and database. To do this, run the following command:
sudo adduser orca
Now you can connect to the Postgres database with the following commands:
# sudo -i -u orca
# orca@sam:~$ psql
Or you can use the following command instead:
sudo -u orca psql
Output
psql (15.0)
Type "help" for help.
orca=#
When you have logged in to your PostgreSQL database on AlmaLinux 9, you can check your current connection information by running the following command:
orca=# \conninfo
In your output you will see:
Output
You are connected to database "orca" as user "orca" via socket in "/var/run/postgres
For more information, you can visit the PostgreSQL Documentation page.
Conclusion
At this point, you have learned to Install PostgreSQL 15 on AlmaLinux 9. By following the guide steps, you can easily add the PostgreSQL repository and start to set up your PostgreSQL including initializing the database and managing your databases.
Hope you enjoy it. You may also like these articles:
Efficiently Check For Security Updates on AlmaLinux 9
Install a Specific Version of PostgreSQL on Ubuntu 20.04
PostgreSQL Setup on Ubuntu 24.04
Install PostgreSQL 15 on Ubuntu 22.04
Install PostgreSQL 14 on Rocky Linux 8
FAQs
What repositories are required for installing PostgreSQL 15 on AlmaLinux 9?
As we said in the guide steps on install PostgreSQL 15 on AlmaLinux 9, you just need to add the latest PostgreSQL repository on your server.
How do I start and enable PostgreSQL 15 service on AlmaLinux 9?
You can easily start and enable your service with the following commands:sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15
How can I upgrade PostgreSQL to version 15 on AlmaLinux 9?
As described in the guide steps above on Install PostgreSQL 15 on AlmaLinux 9, you can easily upgrade and install your service.
Major thanks for the blog article. It is my duty.
A big thank you for your article post. Much thanks again.
Your Welcome