How to install MariaDB 10.2 on CentOS 6

SystemMen - In this article, I will show you how to install MariaDB 10.2 on CentOS 6.

Server requirements

Here are the minimum requirements for the server, I have used a virtual server with such requirements.

  • OS: CentOS 6.9 (Final) 64 bit
  • RAM: minimum 1GB memory
  • HDD: over 5GB free space. Maybe you need more for store databases
  • User: root
  • IP: set static ip, ex:

Added MariaDB repository

The first step is to add MariaDB repository to CentOS 6 server.

You can find more information on how to add a repository here.

Please copy and paste the code below into your terminal. Note that there are no spaces at the beginning of the lines between EOF characters

cat > /etc/yum.repos.d/MariaDB.repo <<"EOF"
# MariaDB 10.2 CentOS repository list - created 2018-03-28 06:30 UTC
name = MariaDB
baseurl =

After adding the repository, you type below command to update new packages from MariaDB repository.

yum update -y

Install MariaDB in CentOS 6

To install MariaDB server on CentOS 6, type the following command.

yum install MariaDB-server MariaDB-client -y
how-to-install-mariadb-10-2-on-centos-6-01 How to install MariaDB 10.2 on CentOS 6
Install MariaDB 10.2 on CentOS 6.

You wait a while for the installation to complete. Then, type the following two commands to enable the service when you reboot and start the service.

chkconfig mysql on
service mysql start

You can then type the following command to check the mysql service status.

service mysql status

And you need to set up the initial security for the MariaDB server using the following command. You will answer some basic questions, set the root password (if not set).


Set rules in IPtables

If you only use MariaDB for the local host, you can skip this section.

If you want to open mysql port 3306 for other servers that can connect to and use the database, then type the following commands.

how-to-install-mariadb-10-2-on-centos-6-02 How to install MariaDB 10.2 on CentOS 6
Set rules to open port 3306 in IPtables.
iptables -I INPUT 1 -m tcp -p tcp --dport 3306 -j ACCEPT
iptables-save > /etc/sysconfig/iptables

And to check the status of the IPtables rule table, you type the command below.

iptables -L

Check MariaDB run

Now on the terminal window, type the following command to login to the mysql service. Remember to type the root password you set.

how-to-install-mariadb-10-2-on-centos-6-03 How to install MariaDB 10.2 on CentOS 6
Login to mysql on CentOS 6.
mysql -u root -p

If your logint succeeds as shown in the image above, you have successfully installed MariaDB 10.2 on CentOS 6. And now you can use the database server.

«« »»
One Comment