In this tutorial, we will explain how to install and secure MariaDB 10.3 on CentOS 8/Rocky.
MariaDB is a free and open-source relational database management system (RDBMS) that can be used as a drop-in replacement for MySQL. Many people in the community, including some of MySQL’s original creators, work on it.
Installing MariaDB on CentOS 8/Rocky
The latest stable release of MariaDB for CentOS 8/Rocky can be found as version 10.3 in the official repositories.
MariaDB 10.3 for CentOS 8/Rocky can be installed by running the following command as root or a user with sudo privileges:
sudo dnf install @mariadb
Using the @mariadb module, MariaDB server and all required components are set up.
Once everything is set up, you can start the MariaDB service and have it start automatically at boot time by typing:
sudo systemctl enable --now mariadb
In order to ensure that MariaDB is up and running, type:
sudo systemctl status mariadb
The results should demonstrate that the service has been activated:
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-12-08 21:05:26 UTC; 15s ago
..
Securing MariaDB
Mysql secure installation, a script included in the MariaDB server package, sets the root password and performs several other security-related tasks.
Type the following to activate the script:
sudo mysql_secure_installation
The MariaDB root user requires a password, which you will be prompted to create. After that, the script will request that you delete the test database, disable the anonymous user, and limit root access to the local machine. Every question needs to be answered with a “Y” (yes).
Now that MariaDB is up and running on your CentOS server, you can begin using it.
Connect to the MariaDB Shell
In order to log in to the MariaDB server as the root user, enter:
mysql -u root -p
When prompted, enter the root password to access the MariaDB shell:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.3.11-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
Conclusion
We’ve covered everything from downloading MariaDB to securing it during installation on CentOS 8/Rocky, plus command line access to the server itself.
It’s time to start making use of your MariaDB server now that you’ve established shell access to it and can begin making new databases and users.
MySQL 8.0 is included with CentOS 8/Rocky. Check out the How to Install MySQL on CentOS 8/Rocky manual if you’d rather set up MySQL than MariaDB. Remember that MariaDB and MySQL cannot coexist on the same server.
Feel free to leave a comment below with any questions, thoughts, or suggestions.