Replacing MySQL with MariaDB

Jacob Allred
#web-dev

MariaDB

Turns out I’ve been living under a rock. I found out a few days ago that there are several drop-in replacements to Oracle MySQL that provide additional features and better performance. After doing some research, I chose to try out MariaDB.

Although MariaDB is a drop-in replacement for MySQL, they don’t really go out of their way to make it easy to switch. It took a fair amount of searching and some trial and error, but eventually I figured it out. Here is what I did for CentOS 5 and CentOS 6:

  1. Backup all databases. I didn’t need to use my backups, but it’d be foolish to attempt something as drastic as switching out your database software without having a fresh backup.
  2. Add the MariaDB repository to yum. Instructions for this part can be found on MariaDB’s website.
  3. Remove MySQL, and install MariaDB at the same time. I accomplished this by using yum shell: yum shell remove mysql* install MariaDB-client.x86_64 MariaDB-common.x86_64 MariaDB-compat.x86_64 MariaDB-devel.x86_64 MariaDB-server.x86_64 MariaDB-shared.x86_64 run exit
  4. Unfortunately, this didn’t quite remove everything so I had to find any MySQL packages that didn’t get removed by running rpm -qa | grep -i ‘^mysql-’ and then rpm —nodeps -ev for any packages that were returned by the rpm command.
  5. Next, I started up MariaDB: /etc/init.d/mysql start
  6. Last, I ran mysql_upgrade to fix any version compatibility issues.

All said and done the entire process took less than 5 minutes and resulted in downtime of about 1 minute.

I’ve read that MariaDB takes more memory than MySQL, but my experience has been the opposite. I have drastically more free memory than before the switch (we’re talking gigabytes of extra free RAM). No idea what was going on with MySQL that it was eating all this RAM that MariaDB doesn’t seem to need. I ran a few informal benchmarks and things seem to be slightly faster. Not enough by itself to justify the effort of switching, but a nice perk.