How to install MariaDB on CentOS

Updated May 01, 2020 · Published September 08, 2016

MariaDB is the community fork and drop-in replacement for MySQL that was started after Oracle acquired MySQL. This step-by-step guide will walk through the installation process for MariaDB on CentOS.

Install and start MariaDB

The following commands will install MariaDB, start the MariaDB server, and set it to automatically starts on system boot.

sudo yum install mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb

Initial configuration

This command initiates a shell script to improve the security of MariaDB by changing some of the default settings. This includes allowing you to set the root password, remove anonymous accounts, disable remote root login, and remove test databases.

sudo mysql_secure_installation

Login for the first time

To login to MariaDB as root, enter the following command. When prompted, enter the root password you assigned during the initial configuration.

mysql -u root -p