How to Install MariaDB 10.6 on Rocky Linux 8

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 would 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.

Prerequisites

  • Recommended OS: Rocky Linux 8.+.
  • User account: A user account with sudo or root access.

Update Operating System

Update your Rocky Linux operating system to make sure all existing packages are up to date:

sudo dnf upgrade --refresh -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@rockylinux ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Rocky Linux.

To use the root account, use the following command with the root password to log in.

su

Create and Import MariaDB Repository

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 MariaDB 10.5 and the most recent 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:

[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 

If you want the alternative more season MariaDB 10.5, then use the following:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1 

Save the file (CTRL+O) and then exit (CTRL+X).

To finish 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

Example output:

How to Install MariaDB 10.6 on Rocky Linux 8

Type “Y,” then press the “ENTER KEY” 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:

How to Install MariaDB 10.6 on Rocky Linux 8

How to Secure MariaDB (Security Script)

When installing MariaDB fresh, default settings 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):

sudo mysql_secure_installation

Next, you will be given a prompt asking you to enter your (MariaDB root password). For now, press the (ENTER) key as the root password isn’t set yet as below:

How to Install MariaDB 10.6 on Rocky Linux 8

Next, type (Y) and press enter to set up the (root) password as below:

How to Install MariaDB 10.6 on Rocky Linux 8

The next series of questions you can safely hit (ENTER), which will answer (Y) to all the following questions which ask you to (remove anonymous users, disable remote root login, and remove the test database). Note the (Y) is capitalized, meaning it is the default answer when you press the (ENTER) key.

This step is essential for MariaDB database security and should not be altered or skipped unless you know what you are doing. Example below:

How to Install MariaDB 10.6 on Rocky Linux 8

Overview of what should have been done above:

  • 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.

This step is essential for MariaDB database security and should not be altered or skipped unless you know what you are doing.

How to Log into MariaDB Instance

Congratulations, you have installed MariaDB on 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:

How to Install MariaDB 10.6 on Rocky Linux 8

To exit the MariaDB terminal, use the following command:

EXIT;

Congratulations, you have successfully installed MariaDB 10.6.

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 acceptable to use. Still, it would be recommended to upgrade to 10.5 as it’s pretty seasoned now compared to 10.6, and there are considerable 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.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!