How to Install MariaDB on CentOS 7

r00t August 3, 2017

Install MariaDB on CentOS 7

In this tutorial we’ll learn how to install MariaDB on CentOS 7. We will also install and configure its prerequisites. MariaDB is a drop-in replacement for MySQL. It is developed by former members of MySQL team who concerned that Oracle might turn MySQL into a closed-source product. Many Linux distributions and companies have migrated to MariaDB.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install MariaDB on CentOS 7

Step 1. First, ensure your system is fully up-to-date by running the following:

yum -y update

Step 2. Installing MariaDB on CentOS 7.

First, adding the MariaDB YUM repository for CentOS systems:

nano /etc/yum.repos.d/MariaDB.repo

Now add the following lines:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Once MariaDB repository has been added, you can easily install the following lines:

yum install mariadb-server mariadb-client

Next, Start the MariaDB service and make it auto-start on system boot:

systemctl start mariadb.service
systemctl enable mariadb.service

With MariaDB installed, we must now turn to security. The next step will perform some basic hardening on the newly-installed database server:

mysql_secure_installation

Follow the prompts as below:

  • Would you like to setup VALIDATE PASSWORD plugin? press Enter here for No
  • Please set the password for root here. New password: Type a secure password here then press Enter
  • Re-enter new password: Re-type the secure password here then press Enter
  • Remove anonymous users? (Press y|Y for Yes, any other key for No) : press y and then Enter here
  • Disallow root login remotely? (Press y|Y for Yes, any other key for No) : press y and then Enter here
  • Remove test database and access to it? (Press y|Y for Yes, any other key for No) : press y and then Enter here
  • Reload privilege tables now? (Press y|Y for Yes, any other key for No) : press y and then Enter here

Once the database server is secured, check it’s installed version and login to the MariaDB command shell as follows:

mysql -V

To access the MariaDB instance, run the following command on the terminal.

mysql -u root -p

Congratulation’s! You have successfully configured MariaDB on your CentOS 7 server.

The Tags:

Leave a Comment

Comments are closed.