mysqli prepared statements | blog about php | ajax autocomplete jquery php | php mysqli tutorial


Is it time to Remove MySQL in favor of MariaDB in Production Servers?

MariaDB is a fork of MySQL, which is community maintained under the GPL v2 license. All code in MariaDB is open source. MariaDB is a binary drop in replacement for MySQL. It includes the XtraDB storage engine as a replacement for InnoDB. Its lead developer is Michael Widenius (also known as "Monty"), the founder of MySQL.

Recently, many popular Linux distributions have moved from MySQL to MariaDB as default database server. Fedora since version 19, Archlinux since March 2013 and OpenSuse. Moreover, Wikipedia is moving to MariaDB and Mozilla is also now using MariaDB.

Famous distributions often used on server environment as Debian and Centos have not yet replace MySQL with MariaDB, but there is a lot of talk about this in their communities. A full list of distributions which include MariaDB is available here.

So, a reasonable question is raised. Is it time to remove MySQL in favor of MariaDB in production servers?

Why switch to MariaDB

At this time, there are not significant differences between MySQL and MariaDB engines, concering main features and performance. Until version 5.5 they both keep the same version numbers. After 5.5, MariaDB developers decided to start a branch numbered as 10, while MySQL went to version 5.6

A possible reason to switch to MariaDB could be the Licensing terms. It is known that MySQL AB acquired by Sun Microsystems on early 2008 for $1bn. Sun acquired by Oracle on April 2009. MySQL Enterprise is a commercial product, but MySQL community edition is still available under the GPL license. However, nobody can be certain for the future licensing policy.

Replace MySQL with MariaDB in Debian Squeeze

I will replace MySQL 5.1 with MariaDB 5.2 in a Debian Squeeze virtual machine (Virtualbox 4.2.4).

This is a testing machine with no critical data. Otherwise, a full database backup must be done:

mysqldump -u root -p > /path/to/backup.sql

MySQL 5.1 is currently running:

mysql -u root -p
(click the thumb for full image)

MariaDB packages are not yet included in official Debian repositories. You can find MariaDB repositories (for every operating system) here:

The whole procedure is quite simple. Select Operating System and get the repositories settings.

(click the thumb for full image)

Edit repositories sources in Debian:

nano /etc/apt/sources.list

Add the following lines:

# MariaDB 5.2 repository list - created 2013-04-01 07:54 UTC
deb squeeze main
deb-src squeeze main

Add MariaDB repositories authorization key (instructions here):

apt-key adv --recv-keys --keyserver 0xcbcb082a1bb943db

Update repositories:

apt-get update

Finally, install MariaDB, using apt-get, as usual:

apt-get install mariadb-client mariadb-server mariadb-client-5.2 mariadb-server-5.2 mariadb-server-core-5.2 mariadb-client-core-5.2

The above command will REMOVE MySQL and will INSTALL MariaDB:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libmariadbclient16 libmysqlclient16 mysql-common
Suggested packages:
  tinyca mariadb-test
The following packages will be REMOVED:
  mysql-client-5.1 mysql-server mysql-server-5.1 mysql-server-core-5.1
The following NEW packages will be installed:
  libmariadbclient16 mariadb-client mariadb-client-5.2 mariadb-client-core-5.2 mariadb-server mariadb-server-5.2 mariadb-server-core-5.2
The following packages will be upgraded:
  libmysqlclient16 mysql-common
2 upgraded, 7 newly installed, 4 to remove and 0 not upgraded.
Need to get 20.8 MB of archives.
After this operation, 8,114 kB disk space will be freed.
Do you want to continue [Y/n]?

Press [Y] to continue. After a while, installation will be completed. MariaDB root user password will be requested:

(click the thumb for full image)

Installation has been completed. mysql command now has the following results:

mysql -u root -p
(click the thumb for full image)

Service name remains mysql, so, you can start or stop the database server as usual

root@mariadb:~# service mysql restart
Stopping MariaDB database server: mysqld.
Starting MariaDB database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..

Existing Databases are not affected from MariaDB installation. All databases still operate fine.

mysql and mysqldump commands still work, configuration files remain the same.

Actually, you will not note any difference from your previous setup. The only difference is that MySQL engine has been replaced from MariaDB engine.

Connecting with PHP5 to MariaDB

In my tests, php extensions (old deprecated extension, mysqli and PDO) seem to work. Some issues may be occur with different API version for php5_mysql and mariadb client:

mysql_connect(): Headers and client library minor version mismatch. Headers:50149 Library:50214


mysqli_real_connect(): Headers and client library minor version mismatch. Headers:50149 Library:50214

A solution would be to recompile mysql and mysqli. An easier workaround would be to suppress php error reporting before database connection and reset it after connection. Something like this:

$conn = mysql_connect('params');
error_reporting('YOUR SETTINGS');

This will not occur with MySQL Native Driver (mysqlnd), but this is not included by default in Debian Squeeze.


It seems that you can move to MariaDB from MySQL without significant problems. But, any change to Production Servers must be done after detailed testing and enough user experience. So, my answer to question:

Is it time to Remove MySQL in favor of MariaDB in Production Servers?

is: not yet.

I use Archlinux on my desktop, so I will have the opportunity to try MariaDB in development environment.

Concerning my server systems, where I use Debian, I will continue to use MySQL, as current Oracle license for community edition of MySQL server allows to use it. When MariaDB will be included officially in Debian, I will make the transition.

What is your opinion about MariaDB? We welcome your feedback. Leave us a comment.

Sign-up for our free email newsletter. Get updates when new tutorials and tips are published. You can unsubscribe anytime with a click.

Your comments are welcomed!

This site actively encourages commenting on any post. Comments are not pre-moderated, but this community does not tolerate direct or indirect attacks, name-calling or insults. Please, read terms of use and Comment Policy at privacy policy.

How to Use PHP Improved MySQLi extension (and Why You Should) Debian 7 Wheezy RC1 LAMP Server Setup Step by Step