Replace MySQL with MariaDB on CentOS

3 years, 10 months ago CentOS, DevOps

MariaDB is an enhanced, drop-in replacement for MySQL offering many speed improvements intended to remain free under the GNU GPL. MariaDB version numbers, up to 5.5, followed MySQL's numbers. Thus, if one uses MariaDB 5.5 one knows that all features from MySQL 5.5 are available. After version 5.5, MariaDB developers decided to start a branch numbered 10, as an attempt to make it clear that MariaDB 10.0 will not import all features from MySQL 5.6; however, they might be imported in future versions. The reason for not including some of the features is that they seem not stable enough to meet MariaDB's quality standards. As a result, and since specific new features have been developed in MariaDB, the developers decided that a major version number change was necessary. In my tutorial, I will show you how to replace MySQL 5.x  with MariaDB 10.0. For this, we have to follow two portions.

  1. Replacing MySQL 5.x with MariaDB 5.5.39
  2. Upgrading MariaDB 5.5.39 to MariaDB 10.0

Hope you understand the method. Please be noted that I have tested it on my CentOS 6.6 vps and hope you will also try it on CentOS 6.x and surely at your own risk. Let's start:

1. First of all we will upgrade all available packages of our server.

yum update

2. Now we will add MariaDB yum repository. Let's open a new file with vim editor:

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

Add these lines in that file:

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

Press Ctrl+ZZ to save the file. Ok, repository added.

3. Now we will remove existing MySQL installation. But before removing it, I suggest you to make an backup of all database on your server so that you may restore them during unwanted database loss at the time of removing it. We will take backup of all databases with a single command:

mysqldump --all-databases > all_databases.sql

That's all. Backup will be done within few minutes depending on your database size. When finished, proceed to remove MySQL by these commands:

service mysqld stop
yum remove mysql-server mysql

4. Let's install MariaDB with yum:

yum install MariaDB-server MariaDB-client

You may have to wait for some minutes at this step. I have noticed that sometimes their server is too loaded to download rapidly. So be patient! :)

5. After installation, we will start and configure MariaDB by these commands:

service mysql start
mysql_upgrade

6. That's all. Now verify the running database engine name and version.

mysql

7. Our Portion-1 is completed. Now we will proceed to Portion-2 for upgrading MariaDB 5.5.39 to MariaDB 10.0. For this, we have to add the MariaDB 10.0 repository. We will simply edit out previous MariaDB.repo file.

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

Now remove all existing lines and add these new lines:

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

8. We will remove repository cache content by this command:

yum clean all

Now update all packages:

yum update

You will see that MariaDB will get latest packages. Just proceed on. :P

9. Then restart MariaDB:

service mysql stop
service mysql start

10. We will make sure that MariaDB will start automatically during boot:

chkconfig mysql on

Now run run mysql_upgrade:

mysql_upgrade

At last, we will check the version again:

mysql

Ok, done. If you face problem to run mysql_upgrade or mysql command, then run it with root. Hope, you have got your MySQL replaced by MariaDB 10.0. I will be back soon with a new topic. Till then Take care, Baby!

Previous Next
Comments
Have you read the comment guideline?

Give me useful, constructive criticism. Spot a typo or an error? Let me know and I will correct it.