Replace MySQL with MariaDB

Posted on Sunday June 30, 2013 / by Eric Potvin

It think it's time for a change. I don't know if you got the news but MySQL man pages silently relicensed away from GPL.

So what about switching to a better, optimize and faster solution? Yes, I am talking about MariaDB!

Before you start, you have to know which version you want between 10.0.x and 5.5. The major difference is MariaDB 10.0 has more features than 5.5:

The full list is available at:

Prepare the installation

sudo apt-get install python-software-properties
sudo apt-key adv --recv-keys --keyserver 0xcbcb082a1bb943db
For 10.0
sudo add-apt-repository 'deb precise main
For 5.5
sudo add-apt-repository 'deb precise main

You can change the source and version at:

If you install version 10.0 you will probably need to recompile the PHP with MariaDB to use the latest version. Otherwise, you will see a notice like this:

---Warning: mysqli::mysqli() [mysqli.mysqli]: Headers and client library minor version mismatch.

You can also create a custom MariaDB sources.list file. To do so, copy and paste the following into a file under /etc/apt/sources.list.d/ (we suggest naming the file MariaDB.list or something similar), or add it to the bottom of your /etc/apt/sources.list file.

# MariaDB 5.5 repository list - created 2013-06-24 12:18 UTC
deb precise main
deb-src precise main

Now, let's install it.

sudo apt-get update
sudo apt-get install mariadb-server mariadb-client libmariadbclient-dev libmariadbd-dev

The service should start automatically, if it does not you can run it manually:

sudo /etc/init.d/mysql start

Test the install

service mysql status
 * /usr/bin/mysqladmin  Ver 9.1 Distrib 10.0.3-MariaDB, for debian-linux-gnu on i686
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Server version		10.0.3-MariaDB-1~precise-log
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/run/mysqld/mysqld.sock
Uptime:			1 hour 2 min 7 sec

Threads: 1  Questions: 118  Slow queries: 0  Opens: 103  Flush tables: 2  Open tables: 79  Queries per second avg: 0.031

Then when you type:


You should see:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 44
Server version: 10.0.3-MariaDB-1~precise-log binary distribution

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

That's it!