How to Migrate MySql to MariaDB in Ubuntu 18.04
We need to perform few steps to migrate the MySql database to Maria database, I have mentioned the steps below:
Log in to your MySql server with root password.
$ mysql -u root -p mysql> show databases;
Now you can migrate all databases or few selected databases to MariaDB. But I’m taking the backup for all databases, You can check the following command.
mysql> exit; $ mysqldump --all-databases --user=root --password --master-data > backupdb.sql
Optionally you can create a backup of my.cnf file somewhere in your system before uninstalling MySql server.
$ sudo cp /etc/mysql/my.cnf /opt/my.cnf.bak
Now stop the MySql server and uninstall MySQL Package with following commands.
$ sudo /etc/init.d/mysql stop
Now we can uninstall the MySql server, associated utilities amd MySql user.
$ sudo apt-get remove mysql-server mysql-client mysql-common $ sudo deluser mysql $ sudo rm -rf /var/lib/mysql
We have completely removed the MySql database from our machine, Now Install MariaDB 10.3 Package.
First you need to add MariaDB repository on your system in order to Install MariaDB.
$ sudo apt-get install software-properties-common $ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 $ sudo add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main' $ sudo apt update $ sudo apt -y install mariadb-server mariadb-client $ sudo cp /opt/my.cnf /etc/mysql/
Now start MariaDB service as follows.
$ sudo /etc/init.d/mariadb start
Finally, we have to import the previously exported databases back to MariaDB server as follows.
$ mysql -u root -p < backupdb.sql
Now we have completed the database migration process from MySql DB to MariaDB.