How to migrate from MySQL to MariaDB on Linux

How to migrate from MySQL to MariaDB on Linux

To migration from MySQL to MariaDB on Linux CentOS you can follow below steps.

1) Check the version of MySQL 

Use below command in MySQL to check the current version of MySQL 
MySQL > Select @@version;

2) Create MariaDB.Repo

Open MariaDB.repot in /etc/yum.repos.d and update with the version of MariaDB you would like to install. I am going to update MySQL 5.6.38 to MariaDB 10.2
# vi /etc/yum.repos.d/MariaDB.repo

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

3) Stop MySQL Service

Stop MySQL Service by using below command
# sudo service mysqld stop 

4) Remove all MySQL installed packages

To check the installed packages you can run below command.
# yum list installed | grep mysql

Remove MySQL Packages

# yum remove Provide the list returned by above command

5) Install MariaDB 10.2 to replace MySQL

Install MariaDB 10.2 by using below command on CentOS linux
# sudo yum install MariaDB-server MariaDB-client 

6) Login to MariaDB and Validate databases 

Login to MariaDB 10.2 and check the version and also check if all databases which were created in MySQL are avaiable. Select some data and also create tables to make sure everything working. 
Note: It is always good idea to take full backups of databases before you perform migration from MySQL to MariaDB.


2 comments: