Are you looking for an easy guide on how to install PostgreSQL 15?
The step-by-step guide on this page will show you how to install PostgreSQL 15 on Rocky Linux 9.
PostgreSQL is a free and open-source RDBMS (relational database management system). It offers SQL language support and can be used for managing database and performing CRUD operations like Create Read Update Delete.
- Minimal Installed Rocky Linux 9
- At least 2GB RAM and 2 CPU
- Sudo User with admin rights
- Stable Internet Connectivity
Without any further delay, let’s jump into the installation steps of PostgreSQL,
1) Enable PostgreSQL 15 Repository
In the default package repository of Rocky Linux 9, postgresql 13.7 is available. So, to install postgresql 15, add its repository by running following command from the terminal.
$ 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 Rocky Linux 9
As we have already configured postgresql repository, now we are all set to install postgresql 15, run
$ sudo dnf update -y $ sudo dnf install postgresql15-server -y
Above command will install postgresql server and its client.
Once package installation is completed, verify the version by running following command,
$ psql -V psql (PostgreSQL) 15.1 $
3) Initialize PostgreSQL 15 database
To initialize the database, run beneath command,
$ sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
4) Start PostgreSQL Service
Run following systemctl commands to start and enable postgresql service,
$ sudo systemctl start postgresql-15 $ sudo systemctl enable postgresql-15
Verify postgresql service status, run
$ sudo systemctl status postgresql-15
Above output confirms that postgreqsql service is up and running.
5) Secure PostgreSQL Database
When we install postgresql database then a user named “postgres” is created automatically and can connect to database without password. So, to connect to database, first switch to user ‘postgres’ and enter psql command. Example is shown below:
$ sudo su - postgres $ psql
So, to secure the database, set the password to user postgres as shown below,
$ sudo passwd postgres $ su – postgres $ psql -c "ALTER USER postgres WITH PASSWORD 'your-password';"
Now, if you switch to postgres user it will prompt you to enter password every time.
$ su - postgres
Perfect, above confirm that our PostgreSQL database is secure.
That’s all from this guide. If you stuck or have any questions, please send us the message using below comments section.
Also Read: How To Use Variables in Bash Script (Simple Guide)