MariaDB is one of the most popular open-source databases next to its originator MySQL. The original creators of MySQL developed MariaDB in response to fears that MySQL will suddenly become a paid service due to Oracle acquiring it in 2010. With its history of doing similar tactics, the developers behind MariaDB have promised to keep it open source and free from such fears as what has happened to MySQL.
MariaDB has become just as popular as MySQL with developers, with features such as advanced clustering with Galera Cluster 4, faster cache/indexes, storage engines, and features/extensions that you won’t find in MySQL.
In the following tutorial, you will learn how to install MariaDB 10.6 on Rocky Linux 8.
- Recommended OS: Rocky Linux 8.+
- User account: A user account with sudo or root access.
Installing MariaDB Repository Rocky Linux
The default MariaDB bundled with the Rocky Linux AppStream repository provides MariaDB 10.3, which is now quite dated. To install a newer version, most will look at either MariaDB 10.5 and the newest stable release MariaDB 10.6. Either can be installed by adding the official MariaDB repository.
First, open up using any text editor and create a MariaDB repository file on your system as follows:
sudo nano /etc/yum.repos.d/mariadb.repo
Next, copy and paste the following lines into the file for the latest version of MariaDB 10.6:
name = MariaDB
baseurl = http://yum.mariadb.org/10.6/rhel8-amd64
If you want the alternative more season MariaDB 10.5, then use the following:
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/rhel8-amd64
Save the file (CTRL+O) and then exit (CLTRL+X).
To finish off installing the new repository, you need to update your system repositories for Rocky Linux to sync the newly added repository. Use the following command to update as follows:
sudo dnf update
Install MariaDB in Rocky Linux
Now that you have installed the repository and updated your system repositories to reflect the new changes, it is time to install MariaDB. To do this, use the following command to install:
sudo dnf install mariadb-server mariadb
Type (Y) to proceed with the installation.
By default, MariaDB will not be enabled on boot, and will it not be switched on, you will need to do both as follows:
To start MariaDB, type the following:
sudo systemctl start mariadb
To start MariaDB on boot by default, type the following:
sudo systemctl enable mariadb
Once complete, you should verify that your MariaDB service is working correctly with the following command:
sudo systemctl status mariadb
You should get (status ok) to know everything is working, example below:
Securing MariaDB in Rocky Linux
When installing MariaDB fresh, the default settings that default are considered weak by most standards and cause concern for potentially allowing intrusion or exploiting hackers. A solution is to run the installation security script that comes with the MariaDB installation.
First, use the following command to launch the (mysql_secure_installation):
Next, follow below:
- Setting the password for root accounts.
- Removing root accounts that are accessible from outside the local host.
- Removing anonymous-user accounts.
- Removing the test database, which by default can be accessed by anonymous users.
Note, you use (Y) to remove everything.
Logging into MariaDB Rocky Linux 8
Now that you have completed the post-installation installation security script, login into your MariaDB database can be done using the following:
sudo mysql -u root -p
You will be prompted to enter your root password, and then you will be successfully logged into the MariaDB database terminal:
Congratulations, you have installed MariaDB on Rocky Linux 8.
Comments and Conclusion
In the tutorial, you have learned how to install the latest version of MariaDB on the latest stable release Rocky Linux 8. Overall, the version on the app stream is fine to use, but it would be recommended to upgrade to 10.5 as it’s quite seasoned now compared to 10.6, and there are huge advantages in performance with upgrading. If you do upgrade, make sure to always back up your database before doing so to avoid countless hours of pain and utter frustration.