In this article, we will have explained the necessary steps to install PostgreSQL on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with
sudo privileges. All the commands in this tutorial should be run as a non-root user.
PostgreSQL is a free and open-source database management system focusing on extensibility and SQL compliance. By installing and running PostgreSQL you get better data management experience for your workloads, both big and small. Additionally, you get security enhancements, optimizations for daily administration, and more conveniences for application developers and DBAs. Some notable PostgreSQL users around the globe are Reddit, Skype, Instagram, BMW, etc.
Install PostgreSQL on Rocky Linux 8
Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.
sudo dnf update sudo dnf upgrade
Step 2. Install PostgreSQL on the Rocky Linux system.
Add the PostgreSQL repository to your Rocky Linux system:
sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo dnf -qy repolist sudo dnf module -qy disable postgresql
With the latest PostgreSQL repository in place, now install the PostgreSQL server using the following command:
sudo dnf install postgresql13-server
Then, you’ll need to initialize database instance before starting the service:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Once complete installation, start and enable the PostgreSQL service using the command:
sudo systemctl enable postgresql-13 sudo systemctl start postgresql-13
You can confirm the version of PostgreSQL installed using the command below:
$ psql -V psql (PostgreSQL) 13.4
Step 3. Create PostgreSQL Database and Role.
- Create a new PostgreSQL Role The following command will create a new role named meymey:
sudo su - postgres -c "createuser meymey"
- Create a new PostgreSQL DatabaseCreate a new database named meymeydb using the createdb command:
sudo su - postgres -c "createdb meymeydb"
- Grant privileges grant permissions to the meymey user on the database we created in the previous step, connect to the PostgreSQL shell:
sudo -u postgres psql
and run the following query:
grant all privileges on database meymeydb to meymey;
That’s all you need to do to install PostgreSQL on Rocky Linux 8. I hope you find this quick tip helpful. For further reading on PostgreSQL’s open-source database, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.