Install MariaDB on Rocky Linux 8.4 [Step-by-Step]

Rocky Linux

Install MariaDB on Rocky Linux - Overview

Before we can start using MariaDB, we have to install it. The MariaDB source code can be compiled to run on a wide variety of different platforms and system architectures, but there are pre-compiled packages available for Windows and Linux, which make the process easier such as:

  • Windows MSI packages
  • Linux YUM packages
  • Linux APT packages
  • Linux and Windows binaries

MariaDB is one of the best widely used open source relational databases in the world that also have NoSQL features, making it more Acceptable. It is a community driven and developed fork of Oracle MySQL.

In this tutorial, we will learn how to install MariaDB on Rocky Linux 8.4. You may also check the mariadb page link for the official instructions to install MariaDB on the Linux Platform.


Lab Environment

Server Machine:
OS: Rocky Linux release 8.4 (Green Obsidian)
Kernel: 4.18.0-305.10.2.el8_4.x86_64
MariaDB Server Version: 10.6
IP Address:

Client Machine:
OS: Red Hat Enterprise Linux release 8.4 (Ootpa)
Kernel: 4.18.0-305.7.1.el8_4.x86_64
MariaDB Client Version: 10.6
IP Address:


Step 1: Create the repository

Configure the official repository by execute the following script,

[root@rockylinux ~]# curl -LsS | sudo bash

Now you can list the MariaDB repository:

[root@rockylinux ~]# yum repolist


Step 2: Install the MariaDB Package

The procedure to install MariaDB on Fedora, Red Hat, and CentOS makes use of the Yellowdog Updater, Modified (YUM) package manager. At first, install some prerequisite packages to avoid the future conflicts:

[root@rockylinux ~]# yum install perl-DBI libaio libsepol lsof boost-program-options rsync libpmem tar socat -y

To install MariaDB from official repository assign --repo parameter in the installation command that will ensure packages will install from MariaDB official repository not from the OS vendor:

[root@rockylinux ~]# yum install --repo="mariadb-main" MariaDB-server -y

The location of configuration file is /etc/my.cnf and the include directory of this file is /etc/my.cnf.d. The /var/lib/mysql/ directory is the default location for our actual database data and the related files such as logs.

MariaDB will look for the file at both locations, but if the files exist at both locations, the options in the file that MariaDB reads last will override the options that it read in the first file.


Step 3: Start MariaDB Instance

Once the mariadb packages are installed, next you can go ahead and start the mariadb service:

[root@rockylinux ~]# systemctl start mariadb.service

Check the status of the service:

[root@rockylinux ~]# systemctl status mariadb.service

You will see the service is active and running in the output:
Install MariaDB on Rocky Linux 8.4 [Step-by-Step]

Enable service to run at boot time:

[root@rockylinux ~]# systemctl enable mariadb.service


Step 4: Secure MariaDB Server

Secure your deployment to meet the business-specific requirements and governance:

From MariaDB 10.4.6, mariadb-secure-installation is a symlink to mysql_secure_installation, the script for enabling you to improve the security of your MariaDB installation.
[root@rockylinux ~]# mariadb-secure-installation

Provided the input:

Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y


Step 5: Local connection to the instance

Using the localhost and default port 3306, you can connect to the running instance,

[root@rockylinux ~]# mariadb -h localhost -p3306 -u root -p

equivalent to:

[root@rockylinux ~]# mariadb


Step 6: Create user for remote connection

For security measure, root user is not allowed to remote connection. For this reason, we need to create a non-root user for allowing remote connection. Locally connect to the database:

[root@rockylinux ~]# mariadb

Create a user test and give permission;

MariaDB [(none)]>CREATE USER test@'%' IDENTIFIED BY 'p';


Step 7: Install MariaDB-client in client machine

Add MariaDB repository in you client machine. In here, the client machine is

[root@client ~]# curl -LsS | sudo bash

Install MariaDB-Client in your client machine:

[root@client ~]# yum install MariaDB-client -y


Step 8: Configure MariaDB server for allowing remote connection

Bind the MariaDB Server IP in /etc/my.cnf.d/server.cnf file:

[root@rockylinux ~]# vim /etc/my.cnf.d/server.cnf

Find the below section,

# Allow server to accept connections on all interfaces.

And change it into the following section:

# Allow server to accept connections on all interfaces.

Here, is the MariaDB server IP.


Step 9: Configure Firewall

Ensure your system firewall settings permit appropriate client access to system resources but block all other requests. Add MariaDB service to the firewall on your server and reload the service:

[root@rockylinux ~]# firewall-cmd --permanent --add-service=mysql
[root@rockylinux ~]# firewall-cmd --reload

Now restart the MariaDB service

[root@rockylinux ~]# systemctl restart mariadb

Check the connectivity from your client machine:

[root@client ~]# mariadb -h -p3306 -u test -p


Step 10: Uninstall the MariaDB

Before uninstall ensure the full backup of your database, because complete uninstall erase everything from you server.

[root@rockylinux ~]# yum remove --repo="mariadb-main" MariaDB-server -y

remove the following directories:

[root@rockylinux ~]# rm -rf /etc/my.cnf.d
[root@rockylinux ~]# rm -rf /var/lib/mysql



In this tutorial, I have tried to cover the installation process of the latest MariaDB 10.6 in Rocky Linux 8.4. We also covered different areas to configure and secure MariaDB, configure firewall, connecting to remote instance of the server.

Views: 142
Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to

Thank You for your support!!

2 thoughts on “Install MariaDB on Rocky Linux 8.4 [Step-by-Step]”

Leave a Comment