How to replace MySQL with MariaDB on CentOS 6

In this article we will explain how to replace your MySQL server with MariaDB 5.5 database on your CentOS 6 server which is very simple. MariaDB is a fork of the MySQL source code. It is free and open source, drop-in replacement for MySQL led by the original developers of MySQL. MariaDB is widely used and several Linux distributions and large companies have already switched from MySQL to MariaDB.

First of all, you should always have a backup of all existing MySQL databases:

# mysqldump --all-databases --user=root --password --master-data > /root/backup.sql
Enter password:

Stop your MySQL service by executing the following command:

# service mysqld stop
Stopping mysqld:             [  OK  ]

Remove all installed MySQL packages:

# yum -y remove mysql*

Even if we removed MySQL, your current MySQL configuration file (my.cnf) is saved as /etc/my.cnf.rpmsave and it can be used later.

Using your favorite text editor create a repository file /etc/yum.repos.d/mariadb.repo containing the following lines:

32bit systems:

name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-x86

64bit systems:

name = MariaDB 
baseurl = http://yum.mariadb.org/5.5/centos6-amd64

Now you can install MariaDB using YUM. Ecexute the following commands:

# yum update
# yum install -y MariaDB-server MariaDB-client MariaDB-devel

After the installation is completed, start MariaDB:

# service mysql start
Starting MySQL.. SUCCESS!

Restore your old my.cnf file:

cp /etc/my.cnf.rpmsave /etc/my.cnf

That’s all. At this point you have successfully replaced MySQL with MariaDB.

# mysql -V
mysql  Ver 15.1 Distrib 5.5.33a-MariaDB, for Linux (i686) using readline 5.1

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script.
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert linux admins to install this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Categories: Tutorials

View Comments

Leave a Comment