MariaDB is an open-source database management system that is widely included as part of the popular LEMP stack (Linux, Nginx, MySQL/MariaDB, PHP/Python/Perl). To manage its data, it employs a relational database and SQL (Structured Query Language). MariaDB is a MySQL fork maintained by the original MySQL developers. It’s intended to be a replacement for MySQL, uses several mysql-related commands, and is the default package on CentOS 7.
This guide will show you how to install the most recent version of MariaDB on a CentOS 7 server.
To follow this tutorial, you will need:
A CentOS 7 with a non-root user with sudo privileges.
Yum will be used to install the MariaDB package, and we will press y when requested to confirm that we want to proceed:
Once the installation is complete, use the following command to start the daemon:
Because systemctl does not display the results of all service management actions, we’ll use the following command to ensure we succeeded:
If MariaDB was successfully started, the output should include the words “Active: active (running)” and the final line should look like this:
Next, use the systemctl enable command to guarantee that MariaDB starts upon boot, which will build the appropriate symlinks.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
After that, we’ll focus on safeguarding our installation.
MariaDB provides a security script that can be used to adjust some of the less secure default configurations for things like remote root logins and sample users. To run the security script, use the following command:
Every step of the script is explained in depth. The first screen asks for the root password, which hasn’t been set, so we’ll enter it as it suggests. We’ll then be required to enter that root password, which we will do.
Then, for the remaining questions, we’ll accept all of the security suggestions by pressing Y and then ENTER, which will remove anonymous users, disable remote root login, delete the test database, and reload the privilege tables.
Finally, now that we’ve protected the installation, we’ll check to see if it’s operational.
We may verify and obtain information about our installation by connecting to the mysqladmin tool, which is a client that allows us to conduct administrative commands. Connect to MariaDB as root (-u root), prompt for a password (-p), and return the version with the following command.
mysqladmin Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Server version 5.5.50-MariaDB
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 4 min 4 sec
Threads: 1 Questions: 42 Slow queries: 0 Opens: 1 Flush tables: 2 Open tables: 27 Queries per second avg: 0.172
This shows that the installation was successful.
In this tutorial, we’ve installed and secured MariaDB on a CentOS 7 server.