MariaDB is a free and community-developed relational database system that is a compatible drop-in replacement for the hugely popular MySQL database management system.
It was forked from MySQL after the original developers of MySQL expressed their misgivings with the acquisition of MySQL by Oracle. Since then, MariaDB is guaranteed to remain free and open source under the GNU license.
MariaDB is massively popular for its fast performance, scalability, stability, and robustness. It is compatible with a wide range of operating systems including Linux, FreeBSD, Mac, and Windows.
The rich set of storage engines, plugins, and other cool tools that it provides make it an ideal option for various use cases such as data analytics, data warehousing, transactional processing, and so on. In fact, it’s a key component of the LAMP & LEMP stacks which are used for hosting web applications.
Key Features of MariaDB include:
- Galera clustering technology.
- New Storage engines such as InnoDB, XtraDB, Aria, TokuDB, CONNECT, and SEQUENCE to mention a few.
- Faster and improved replication.
- Advanced thread pool capable of supporting up to 200,00+ connections.
- New features such as system-versioned tables, anchored data types, and UNIX socket authentication to mention a few.
In this article, we walk you through how to install the MariaDB database server on Rocky Linux 8 and AlmaLinux 8.
Step 1: Add MariaDB Repository in Rocky Linux
By default, the Rocky Linux AppStream repository provides MariaDB 10.3. However, this is not the latest version. At the moment, the current stable release is MariaDB 10.6.
To install the latest version, create a MariaDB repository file on your system as follows.
$ sudo vim /etc/yum.repos.d/mariadb.repo
Paste the lines shown.
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.6/rhel8-amd64 module_hotfixes=1 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
Then save the changes and exit from the file.
Next, update the system repositories for Rocky to register the newly added repository.
$ sudo dnf update
Step 2: Install MariaDB in Rocky Linux
With the repository in place, move along and install the MariaDB database server as shown:
$ sudo dnf install mariadb-server mariadb
Once installed, enable MariaDB service to start on boot time and start the service using the following commands.
$ sudo systemctl enable mariadb $ sudo systemctl start mariadb
Then verify the running status of MariaDB.
$ sudo systemctl status mariadb
The output shows that everything is working as it should.
Step 3: Secure MariaDB in Rocky Linux
MariaDB comes with default settings that are weak and present security risks that can cause the database server to be exploited by hackers. Therefore, we need to take additional measures to secure the database server.
To do so, we will run the script below.
$ sudo mysql_secure_installation
First, set the root password.
For the remaining prompts, press
‘Y’ to purge anonymous users, disallow remote root login and remove the test database which is not required in production and finally save the changes.
To log in to the MariaDB database server, run the following command
$ sudo mysql -u root -p
Provide the root password that you configured in the previous step and press ENTER to access the MariaDB shell.
And there you go. We have successfully installed the MariaDB database server on Rocky Linux 8. Remember, you can still use the version provided by the AppStream repository which will work just fine. However, if you are looking to install the latest version of MariaDB, then adding the repository will do the trick.