How to Install PostgreSQL 15 on RHEL 9 Step by Step
This post covers how to install PostgreSQL 15 on RHEL 9 system step by step.
PostgreSQL is an open-source, multi-platform, robust and highly extensible database server based on the SQL language. It provides the features like data integrity, build applications and create fault-tolerant environments.
- Minimal Installed RHEL 9
- At least 2GB RAM and 2 CPU
- Sudo User with admin rights
- Red Hat Subscription or locally configured Repository
- Stable Internet Connectivity (In case of Red Hat subscription)
Without any further delay, let’s jump into PostgreSQL 15 installation steps.
1) Enable PostgreSQL 15 Package Repository
PostgreSQL 15 is not available in the default package repositories of RHEL 9. So, let’s first enable its DNF/yum package repository using following dnf command.
$ sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y
2) Install PostgreSQL 15 on RHEL 9
In step 1, we have already configured PostgreSQL 15 package repository, so to install it, run the beneath dnf command.
$ sudo dnf install postgresql15-server -y
Once postgresql and it’s dependencies are installed, verify its version using following psql command.
$ psql -V psql (PostgreSQL) 15.1 $
Above command’s output shows PostgreSQL 15.1 is installed on the system. Now, let initialize its database in the next step.
3) Initialize PostgreSQL Database (initdb)
To initialize PostgreSQL 15 initdb database, run
$ sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
4) Start PostgreSQL 15 Service
Run the following systemctl commands to start and enable postgresql 15 service.
$ sudo systemctl start postgresql-15 $ sudo systemctl enable postgresql-15
To verify its service status, run
$ sudo systemctl status postgresql-15
Above output shows that postgresql service is up and running.
5) Securing PostgreSQL 15 Database
By default, postgresql database is not secure, one can easily switch to postgres user without any password and start using psql as shown below:
Now to secure database, set password to postgres user using passwd command.
$ sudo passwd postgres $ su – postgres $ psql -c "ALTER USER postgres WITH PASSWORD ‘xxxxxxxxxxx';"
Output of above commands,
Now. Let’s try to switch to postgres user and connect to database. This time it should prompt you to enter password first,
$ su - postgres Password: $ psql
Perfect, above output confirms that postgres user and database is secure now.
That’s all from this post, please do post your queries and feedback on below comments section.
The post How to Install PostgreSQL 15 on RHEL 9 Step by Step first appeared on .