How to set up MariaDB on Rocky Linux 8

There are several ways that we can install and maintain the databases, including commercial products like Microsoft SQL Server or Oracle. But with open-source software, there are often many, many choices for various platforms and operating systems.

In this tutorial, I will show you how easily we can install and configure MariaDB on Rocky Linux in just a few steps. We will install the packages directly from the repository of Rocky Linux. This means that your database software is being kept up-to-date by package maintainers who are experts in maintaining their particular flavor of software. These maintainers also test updates thoroughly before making them available to users, so you don’t have to worry about whether or not a new version of your software is going to work correctly on your system.

The MariaDB relational database management system is an open-source, multi-threaded system licensed under the GNU Public License (GPL), well-suited to replace MySQL databases. It is fast, scalable, and robust. In terms of performance, MariaDB is superior to MySQL. MariaDB (often called MySQL) because it has very similar features and functionality to MySQL. A typical implementation would be to replace the MySQL module in the widely used LAMP (Linux, Apache, MySQL, PHP) stack. Since the company was acquired by Oracle Corporation in 2009, the developers of the original project created MariaDB as a fork of MySQL.

The MariaDB database is available in two editions: Community and Enterprise. Community editions are available to anyone for free, whereas Enterprise editions require a subscription. This article will show you how to install and configure the latest version of MariaDB Server on a Rocky Linux 8.


What are the main advantages of using MariaDB over MySQL?

* Speed, Efficiency, Security, and Manageability.

* The thread pool in MariaDB is capable of running faster and supporting up to 200,000+ connections.

* PBXT, Aria, XtraDB, Maria, and FederatedX are some of the 12 new storage engines.

* The new version supports new commands such as WITH and KILL and is compatible with JSON.

* Furthermore, MariaDB includes query-specific optimizations for disk access, joins, subqueries, derived tables and views,
execution control, and even explaining statements.

* And many more...

Prerequisites :

Operating System       :    Rocky Linux / RHEL /CentOS /Fedora
package                :    mariadb-server mariadb
User account           :    root user or user account with sudo privileges
Recommended to run all the administrative commands as with sudo privilege instead of root.

Difficulties in setting up sudo users? Click here to find the steps.

For those new to Rocky Linux, you can check the Rocky Linux installation steps by visiting this link.

My Lab Setup :

As part of the lab setup, I'm running MariaDB-Server on a Rocky Linux box.

MariaDB Server:

Operating System    :   Rocky Linux release 8.5 (Green Obsidian)
Hostname            :   db01.linuxteck
IP Address          :
Step 1: Install MariaDB package

As a best practice, you should update your operating system before installing the package.

$ sudo dnf update


The MariaDB-server package can now be installed by executing the following command: However, the AppStream repository of Rocky Linux only contains a rather outdated version of MariaDB, which is 10.3. You can verify that with the following command in the terminal.

$ sudo dnf module list mariadb

how to list mariadb modules


At the time of writing this article, we have version 10.9. However, the MariaDB Foundation does not recommend using the latest version for production use. In a production environment, version 10.6 is recommended, but in a development or test environment, you can install the latest version. Throughout this article, we will be using the stable version of MariaDB which is version 10.6. To install the customized version of MariaDB, you simply need to create a MariaDB repository and add the appropriate version manually to your system as follows: Here is the MariaDB 10.6 version.

$ sudo vi /etc/yum.repos.d/mariadb.repo

name = MariaDB
baseurl =


The above lines need to be added to the MariaDB.repo file. On the BASEURL line, you can see the version of the repository file we added. Likewise, you can adjust the version to suit your needs. Once the lines are added, you can save and exit the file.

As soon as we add the new repository version, we must update the Rocky Linux repository before installing the Mariadb-Server.

$ sudo dnf update

Following the update of the system, you can proceed to install the MariaDB server using the following command.

$ sudo dnf install mariadb-server mariadb

Install mariadb server

After installation, the following command will show you how to start, enable, and check the status of mariadb in linux.

$ sudo systemctl start mariadb


$ sudo systemctl enable mariadb


$ sudo systemctl status mariadb

You can see from the screenshot below that MariaDB is running and active.

systemctl status mariadb

Step 2: Securing MariaDB Server


The default configuration of MariaDB is less secure, which is highly problematic, meaning anybody can interact with the database. To prevent intruders or hackers, we must perform security upgrades/fixes. You can accomplish this by executing the built-in PERL application that comes with the MariaDB package. By running this script, you can add a layer of security while installing the Database server. Using the script we can change MariaDB's root password, remove anonymous user accounts, disable root logins within localhost's backyard, remove test databases, and reload privileges. Following the successful execution of the script, you can declare that you have added additional measures to safeguard MariaDB.

Since version 10.4.6, MariaDB no longer uses the old Mysql prefix and replaces it with the new MariaDB-specific command. In other words, formerly we would have executed a PERL script as "mysql_secure_installation" but now we execute it as "mariadb-secure-installation". Since we are using MariaDB 10.6, we need a new command. If you want to find out what version of MariaDB you are using, use this command "$ mariadb -V".

$ sudo mariadb-secure-installation


Once you have executed the above command, you will be prompted with the following series where you need to make a few changes to the MariaDB installation security options.

1. To begin, you will be prompted to enter your current database's root password. Since this is a brand new installation and no root password has been set. To continue, you can press the enter key.

2. You can now switch to unix_socket authentication by typing "Y" and pressing the enter key.

3. If you wish to change the MariaDB root password, you should type "Y" and press enter, and then you should type in the new password (twice), and then press enter key to confirm the change.

From here on, you will be asking a series of basic questions. For your convenience, we have provided the answers to the below screenshots. We recommend that you acknowledge "YES" for each of the following: As a result of the long output, I have split the screenshots into three parts. The first one shows how to set the root password.


Following that, you will see the remaining steps.

sudo mariadb-secure-installation

sudo mariadb-secure-installation


That's it. We have implemented the security measures successfully. You can now attempt to log in to MariaDB using the following command: By executing the below command, you will be prompted to type in the password you have previously set for the MySQL root account. Now enter that password and press enter to access your SQL shell.

$ mysql -u root -p


It means that you are trying to access the MySQL database. The "-u" parameter specifies the MySQL user name, and the "-p" parameter indicates the password for the MySQL user.

mysql -u root -p


Those who are familiar with SQL administrative commands can use the SQL shell or use a MySQL client such as PHPMyAdmin, workbench, etc. It will enable you to manage your MySQL/MariaDB database easily. Here, for testing purposes, let's use one of the SQL commands in the SHELL prompt . For example, you can use the "SHOW DATABASES" command to see all of the databases available on MariaDB:


More administrative SQL commands can be found here


That's it. We hope this article has helped you understand how to Install MariaDB 10.6 Database Server step-by-step on Rocky Linux 8. Drop me your feedback/comments. Feel free to share this article with others if you like it.

Support My Work

Thank you for your support and for being a part of my journey, I would be very grateful if you could consider buying me a coffee. The contributions you make will help me to continue to produce quality content and enhance my readers' experience.

Buy Me A Coffee

Thank you for your endless support!


About John Gomez

John Britto Founder & Cheif-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 10+ years of experience in Linux and Open Source technologies.

View all posts by John Gomez →

Leave a Reply

Your email address will not be published.