When it comes to (relational) databases, MySQL has been an undisputed winner.
But now it has serious competition!
Unlike other database comparisons, the MySQL vs. MariaDB one has minimal real, objective merit. They’re almost the same (and a while back, were the same!), have the same directory structures and syntax, and same performance.
Yes, after the release 10 of MariaDB, things started diverging faster, but even the command to run MariaDB is called `mysql`!
So, while you’re here to learn how to migrate from MySQL to MariaDB, I think it’s going to be very interesting to learn where this sudden competitor sprang up from. If you are new to MariaDB, then you may consider taking this online course.
The story behind MariaDB
Without launching into full encyclopedia mode, let me go over the main points.
MySQL was initially released in 1995 by Michael Widenius to offer an alternative to restrictive, pricey offerings such as Microsoft’s SQL Server or Oracle’s suit. And the rest, as they say, if history: MySQL became so popular that pretty soon, developers forgot that SQL and MySQL were two different things. Estimates vary, but it’s fair to say that MySQL commands close to 45% of the database market as of writing.
To cut a long story short, MySQL was acquired by Sun Microsystems, which was in turn acquired by . . . Yes, Oracle. As a result, the largest open source database engine was now owned by the most successful commercial database company in the world. To the original creators of MySQL, this was the death knell for a database engine used and loved by millions.
They feared that Oracle only cared for the astounding user base of MySQL, would slowly kill off the project’s spirit, commercialize it heavily.
As a result, a pure-GPL fork of MySQL, called MariaDB, was born in 2010.
Now, should you be migrating to MariaDB?
It’s hard to argue one way or another, and for independent developers, it doesn’t make a difference. Popularity-wise, MariaDB is still nowhere close to MySQL but is getting known.
For instance, the WordPress installation FAQ mentions MySQL and MariaDB in the same breath.
For larger teams working on long-term solutions, it depends on how much they trust Oracle to keep the original ideals of MySQL intact. It’s hard to say they’d overnight enforce draconian licensing terms, but it’s not unthinkable also.
Combine this with the fact that MariaDB can innovate faster and soon will be incompatible with MySQL on a fundamental level, and there’s a strong case to make a switch. Other than that, it doesn’t matter as of now, and apart from some paranoid businesses, users of MySQL are staying where they are.
How to migrate from MySQL to MariaDB?
MySQL to MariaDB is one of the most ridiculously easy migrations you’ll ever do in your life. There’s nothing to be done, and you’ll be left thinking “That’s it?!” after it’s over. Essentially, all you have to do is:
- Make sure your package manager has access to MariaDB.
- Stop MySQL.
- Install MariaDB
Yes, that’s it!
For instance, if you’re on Ubuntu 18.04, the first step is to add MariaDB sources to your system like this:
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,arm64,ppc64el] http://suro.ubaya.ac.id/mariadb/repo/10.3/ubuntu bionic main' sudo apt-get update
Now it’s time to stop MySQL:
sudo service mysql stop
and then install MariaDB, which will launch upon completion:
apt install mariadb-server
And next comes . . . Nothing!
Yes, that’s it — you’ve successfully migrated from MySQL to MariaDB. I know, it’s impossible to believe that.
I mean, surely there has to be more to it than just 2-3 commands? What about dumping and importing databases? What about database users, passwords, and privileges? What about optimization settings (for DB admins)?
Honestly, there’s zero need for any of it. MariaDB is a “drop-in” replacement for MySQL. Remember that it’s just an open source fork of the existing MySQL project, and so is necessarily the same. As I said before, the differences will increase with time, but as of now, there’s nothing to do, other than stopping MySQL and installing MariaDB. 🙂
If you still don’t believe (which I admire!), I encourage you to head over the official migration docs, which make the reassuring claim:
You’ve decided to move from MySQL to MariaDB, but you’re a little nervous. The last thing you want is to become mired in a slough of brokenness. Don’t worry, because MariaDB is designed to be a drop-in replacement for MySQL. You should be able to install MariaDB over your MySQL server, and then go about your business without drama.
I hope that settles it. Don’t worry, I’ve personally migrated a few MySQL databases without any troubles whatsoever, so there’s nothing to fear. 🙂
Finally, If you’re on a different platform than Ubuntu 18.04, MariaDB has a helpful tool that can generate the necessary commands for you just to copy and paste.
Before I close this article, a word of caution: please take a backup of your MySQL data files before you perform an upgrade.
Equally importantly, please conduct thorough research on the compatibility of the MariaDB version you’re installing if you’re using some pre-built third-party tools (like Magento, Drupal, etc.).