MariaDB database server is a high-performance, robust, and feature-rich relational database server that provides an SQL shell prompt for database management. The database server was created by developers who came up with MySQL soon after the acquisition of MySQL by Oracle in 2009. Simply put, it’s a fork on MySQL.
MariaDB is available under the GPL v2 and is popular for its scalability, flexibility, and scalability. It provides a wide array of plugins, storage engines such as InnoDB, TokuDB, and CONNECT, Galera clustering, faster replication among other cool features & tools that enhance its performance. MariaDB is an integral component in the LAMP stack is used by giant companies such as Google Inc and Wikipedia.
MAriaDB comes in two editions: The MariaDB community edition which is free to download and use and MariaDB Enterprise Server. In this guide, we explore how you can install MariaDB on Rocky Linux 8.
Step 1: Add the latest MariaDB repository
The AppStream repository, by default, provides MariaDB 10.3 which, currently, is not the latest version.
You can verify the versions provided by the repository by running:
$ sudo dnf module list mariadb
To install the latest version, which by the time of writing is MariaDB 10.6, you need to add the repository manually on your system.
So, create a repository file.
$ sudo vim /etc/yum.repos.d/mariadb.repo
Next, paste the lines shown to add the repository and save the changes.
[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
Once added, update Rocky Linux packages and repositories as shown.
$ sudo dnf update
Once you have updated your system, you are now ready to install the MariaDB server.
Step 2: Install MariaDB database server
Moving on, install MariaDB database server and client using the command:
$ sudo dnf install mariadb-server mariadb
The command installs the MariaDB server and client alongside other dependencies. During the installation, press ‘Y’ when prompted to import the MariaDB GPG key.
Step 3: Enable and Start MariaDB database server
Now that MariaDB is successfully installed, you need to enable it to start on boot time without intervention as shown.
$ sudo systemctl enable mariadb
With the MariaDB database server enabled on boot, start the MariaDB daemon.
$ sudo systemctl start mariadb
You can confirm the status of the database server as follows.
$ sudo systemctl status mariadb
To log in to MariaDB, execute:
$ sudo mysql -u root -p
When prompted for a password, just press ENTER to access the MariaDB shell.
Step 4: Secure MariaDB database server
As you have noted, The database server does not have a root password configured. Virtually anyone can access the database server, and this presents a huge security risk for the system. We will go the extra mile and secure the database server by setting the root password and performing additional tweaks.
To do so, run the script shown.
$ sudo mariadb-secure-installation
When prompted to enter the current root password, just press ENTER and switch to unix_socket authentication by pressing ‘Y’.
Then press ‘Y’ to change the root password and provide a strong password.
For the remaining prompts, press ‘Y’ to tweak the database server to the recommended settings. This provides fundamental security from breaches. By doing so, you get rid of anonymous users, block remote root login, and purge the test database which shouldn’t be in the production environment.
Next time when you log in to the MariaDB shell, you will be prompted for the root password.
That was an overview and step-by-step installation of the MariaDB server. In this tutorial, we have installed the latest version of MariaDB – MariaDB 10.6 on Rocky Linux 8.