How to replace MySQL with MariaDB on CentOS 6
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:
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-x86 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
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.