MariaDB is a free and open-source database management system that is frequently used in place of MySQL in the well-known LAMP (Linux, Apache, MySQL, PHP, Python, and Perl) stack.It is intended to be an easy-to-use alternative to MySQL.
On a CentOS 8 server, we will demonstrate how to install MariaDB’s most recent version in this tutorial.If you want to know the difference between MySQL and MariaDB, MariaDB is the preferred package and should work just as well as MySQL.Check out the guide on how to install MySQL on CentOS 8 if you specifically require MySQL.
You will need a CentOS 8 server with a sudo-enabled user other than root to follow this tutorial.The Initial Server Setup with CentOS 8 guide has more information on how to set up a user with these privileges.
Step 1 — Installing MariaDB
First, install the MariaDB package with dnf:
sudo dnf install mariadb-server
The action will be confirmed by you.To proceed, press y and then ENTER.
Start the service with systemctl after the installation is complete:
sudo systemctl start mariadb
Then, check the service’s status:
The final line should look like this: If MariaDB has successfully started, the output should show active (running).
Next, let’s use the systemctl enable command to make sure MariaDB starts at boot:
sudo systemctl enable mariadb
MariaDB is currently running and has been set up to run at startup.After that, we will concentrate on protecting our installation.
Step 2 — Securing the MariaDB Server
MariaDB comes with a security script that lets you change some of the less secure default settings for things like sample users and remote root logins.To run the security script, use the following command:
Every step is explained in great detail in the script.Since the root password has not yet been set, we will press ENTER as recommended during the first step.We will then be asked to enter that root password.Keep in mind that this is not for the root user of your CentOS server; rather, it is only for the root database user.
To set a password for the root database user, press Y and then ENTER, then follow the on-screen instructions.
We will accept all subsequent security suggestions by pressing y and then ENTER after updating the password.The test database will be deleted, remote root login will be disabled, anonymous users will be removed, and the privilege tables will be reloaded.
We will connect to the database to check that the installation is functioning now that it has been secured.
Step 3 — Testing the Installation
By connecting to the mysqladmin tool, a client that allows you to run administrative commands, we can verify our installation and obtain information about it.Connect to MariaDB as root (-u root), prompt for a password (-p), and return the version with the following command.
mysqladmin -u root -p version
You installed MariaDB to serve as an SQL server in this guide.You also secured the server during the installation process.You could also create a separate administrative user with a password.