How To Install MariaDB on Rocky Linux 9
In this tutorial, we will show you how to install MariaDB on Rocky Linux 9. For those of you who didn’t know, MariaDB is a popular, free, and open-source database management system commonly used as an alternative for the MySQL portion of the popular LAMP. It uses MySQL as its primary storage engine, but it is also lightweight, secure, and features in-memory ACID transactions.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the MariaDB 10 database on Rocky Linux. 9.
Prerequisites
- A server running one of the following operating systems: Rocky Linux 9.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install MariaDB on Rocky Linux 9
Step 1. The first step is to update your system to the latest version of the package list. To do so, run the following commands:
sudo dnf check-update sudo dnf install dnf-utils
Step 2. Installing MariaDB Database on Rocky Linux 9.
By default, MariaDB is available on Rocky Linux 9 base repository. Now run the following command below to install the latest stable version of MariaDB to your system:
sudo dnf install mariadb-server mariadb
Once the installation is complete, start the MariaDB service and enable it to automatically start on boot by running the following command below:
sudo systemctl enable mariadb --now sudo systemctl start mariadb sudo systemctl status mariadb
To check the version of MariaDB installed, run the command below:
mariadb --version
Step 3. Securing MariaDB.
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation
script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
mysql_secure_installation
Configure it like this:
- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y
Step 4. Accessing the MariaDB.
You can now try to access the database with the set root user password:
mysql -u root -p
Now create a database user, database, and assign control over the created database to the user:
MariaDB [(none)]> CREATE USER idroot@localhost IDENTIFIED BY "Your-St0nge-Passwd"; MariaDB [(none)]> CREATE DATABASE idroot_db; MariaDB [(none)]> GRANT ALL ON idroot_db.* TO idroot@localhost; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit
Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing the MariaDB database server on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official MariaDB website.