Replace MySQL with MariaDB on CentOS
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.
- Replacing MySQL 5.x with MariaDB 5.5.39
- 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:
First of all we will upgrade all available packages of our server.
Now we will add MariaDB yum repository. Let’s open a new file with vim editor:
Add these lines in that file:
Press Ctrl+ZZ to save the file. Ok, repository added.
- 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:
That’s all. Backup will be done within few minutes depending on your database size. When finished, proceed to remove MySQL by these commands:
- Let’s install MariaDB with yum:
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! :)
After installation, we will start and configure MariaDB by these commands:
That’s all. Now verify the running database engine name and version.
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.
Now remove all existing lines and add these new lines:
- We will remove repository cache content by this command:
Now update all packages:
You will see that MariaDB will get latest packages. Just proceed on. :P
Then restart MariaDB:
We will make sure that MariaDB will start automatically during boot:
Now run run mysql_upgrade:
At last, we will check the version again:
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!