MariaDB to MySQL – Steps to Move Data

on Tutorial • February 4th, 2020 • Write for Hevo

MariaDB and MySQL are two widely popular relational databases which boast many of the largest enterprises as their clientele. Both MariaDB and MySQL are available in two versions – A community-driven version and an enterprise version. But the distribution of features and development processes in the community and enterprise versions of MySQL and MariaDB differ from each other. MariaDB and MySQL are closely related in the sense that MariaDB is a fork of MySQL. Even though MariaDB claims itself as a drop-in replacement for MySQL, because of the terms of licensing and enterprising support contracts, many organizations migrate between these two according to their policy changes. This blog post will cover the details of how to move data from MariaDB to MySQL.

Introduction to MySQL and MariaDB

MySQL first appeared in 1995 as an open-source project and was later acquired by Sun microsystems. Sun was acquired by Oracle leading to MySQL becoming an Oracle product. Many of the biggest names in the industry like Facebook, Github, etc. use MySQL for their day to day operations. MySQL provides a comprehensive SQL shell that can even interpret Python and Javascript. MySQL supports JSON as table fields and allows users to query based on JSON keys. It provides a secure authentication layer with support very granular field-level controls for reading and writing. MySQL supports table encryption as well as binary log encryption. Development processes in MySQL are more closed when compared to MariaDB and the issue trackers refer to many oracle internal sources that are closed for public.

MariaDB started as a fork of MySQL just before the acquisition of Sun microsystems by Oracle. The objective was to establish a purely open-source alternative to MySQL anticipating possible licensing constraints imposed by Oracle. Ever since Maria DB follows a different development path as compared to MySQL with the objective being to remain as similar as possible to MySQL from a user’s perspective. Many industry stalwarts like Microsoft and Alibaba back MariaDB and it is used by many of the top organizations for its day to day operations. MariaDB has a comprehensive SQL layer and provides a shell. It provides similar encryption capabilities as MySQL and is known to offer slightly higher performance and faster development cycles because of its open-source roots.

How to move data from MariaDB to MySQL

There are two popular methods to perform MariaDB to MySQL data migration.

Method 1: Build a Custom Code using the mysqldump command to move data from MariaDB to MySQL

Method 2Use a fully managed Data Integration Platform Hevo Data

For the scope of this blog post, the second approach will be covered extensively. Towards the end, you can also find the limitations of this method and ways to overcome them.

Moving data from MariaDB to MySQL Using Custom Code

Since both the databases provide the same set of underlying tools, it is very easy to copy data from MariaDB to MySQL. The following steps detail how to accomplish this.

  1. From the client machine, use the below command to create a complete dump of the database in MariaDB.
    mysqldump -u username -p database_name > source_dump.sql

    This command creates a source_dump.sql file.

  2. Move the file to a machine that can access the target MySQL database. If the same machine has access to the target database, this step is not relevant.
  3. Log in as root to the target MySQL database
    mysql -u root -p password
  4. In the MySQL shell, execute the below command to create a database.
    CREATE DATABASE target_database;

    Where target_database is the name of the database to which data is to be imported.

  5. Exit the MySQL shell and go to the location where the source_dump.sql is stored.
  6. Execute the below command to load the database from the dump file.
    mysql -u username -p new_database < source_dump.sql

That concludes the process. The target database is now ready for use and this can be verified by logging in to the MySQL shell and executing a SHOW TABLES command. Even though this approach provides a simple way for a one-off copy operation between the two databases, this method has a number of limitations. Let’s have a look at the limitations of this approach.

MariaDB to MySQL: Limitations of Custom Code Approach

  1. In most cases, the original database will be online while the customer attempts to copy the data. mysqldump command is a costly execution and can lead to the primary database being unavailable or slow during the process.
  2. While the mysqldump command is being executed, new data could come in resulting in some leftover data. This data needs to be handled separately.
  3. This approach works fine if the copying operation is a one-off process. In some cases, organizations may want to maintain an exact running replica of MariaDB in MySQL and then migrate. This will need a complex script that can use the binary logs to create a replica.
  4. Even though MariaDB claims itself as a drop-in replacement, the development has been diverging now and there are many incompatibilities between versions as described here. This may lead to problems while migrating using the above approach.

The above method provides a simple approach for a one-off migration between MariaDB and MySQL. But, this is not suitable for continuous or periodic copying operation. This method also suffers from some other limitations mentioned above. An alternative could be using a data integration platform – Hevo which can handle such migrations in an elegant way without having to write a single line of code.

An Easier Way to Move Data from MariaDB to MySQL:

Using a no-code, easy to use Data Integration solution like Hevo, you can load your data from MariaDB to MySQL in a matter of minutes. You can achieve this on a simple point and click visual interface. Here are the steps to replicate MariaDB to MySQL using Hevo:

  1. Connect to your MariaDB Database
  2. Select the replication mode: (i) Full Table dump (ii) Load data using custom query (iii) Replicate Data using binlog
  3. Configure your MySQL database and move data

With Hevo, you can achieve seamless and efficient data replication from MariaDB to MySQL. Hevo can help you move data from not just MariaDB, but a wide array of additional data sources. This makes Hevo the right partner to cater to your evolving data needs.

Sign up for a 14-Day free trial with Hevo and experience a hassle-free data migration experience from MariaDB to MySQL.

No-code Data Pipeline for MySQL