Making the Switch From MySQL to MariaDB

New doesn’t always mean better, but in this case… new is better.


Over the last few days, we’ve been working on some server optimizations here at Obstance. Part of the process was making the switch from MySQL to MariaDB. Or maybe more appropriately worded, upgrading to MariaDB. It’s such an insanely simple process, you’ll wonder why you haven’t done it yet. We’ll let you know how to do it — we’ll be going into how we did it on Ubuntu 12.04 LTS (Precise) and MySQL 5.5, but it will not be much different for other distros.

Firstly, what is MariaDB? MariaDB is a fork of MySQL, a database management system. During the time Oracle was making an acquisition of MySQL, there grew some concerns on the direction the commercial company was going to handle the licensing and copyright of the open-source software. Many developers, including one of the founders of MySQL, petitioned against this acquisition but ultimately made no difference. The acquisition went through. A fair bit prior to this happening, MariaDB was being forked as a GPL software. Fast forward a few years and a bunch of other stuff happening, and here we are today. Ahem.

Back up your MySQL databases

So let’s move on and get this thing set up. MariaDB is a drop-in installation, so the process goes at lightning speed. But before doing anything, make a backup of your MySQL databases anyway. A quick way of doing this is by doing a mysqldump.

sudo mysqldump -p --all-databases > db_backups.sql

This will grab all of your databases, so make sure to save that file both on your server and your local computer. You likely won’t need it, but keep it until you’re sure your MariaDB drop-in has gone smoothly.

Grab the MariaDB repo

Here’s the good stuff. The best thing to do is to click here to customize your configuration, particularly because you’ll need the key and make sure you’re getting the latest stuff that you need. Here’s what we had:

sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository 'deb http://mirror.jmu.edu/pub/mariadb/repo/10.0/ubuntu precise main'

This will net you the needed software and add the MariaDB repository. Go ahead and install it:

sudo apt-get update
sudo apt-get install mariadb-server

Go through the prompts. This process will remove MySQL and drop MariaDB in, all good to go and backwards compatible. For the password prompts, hit enter to keep your current password. You’ll also get a prompt on whether you want to keep your previous my.cnf file or download the one that comes packaged in the repository you just installed. My suggestion is to keep the one you’ve been using, especially if you’ve strayed from the defaults. Just look up the additional features that MariaDB offers to customize it a bit more!

That’s all there is to it. They’ve really made it a simple process and the backwards compatibility pretty much ensures that you won’t get tangled up with fixing problems from upgrading. Make the switch today. Wikipedia did. Google did. Why shouldn’t you?