Switching from MySQL to MariaDB using MacPorts


MySQL has been a cornerstone of the LAMP stack (and, dare I say, the web in general). MariaDB, for those that don't know it yet, describes itself like this:

An enhanced, drop-in replacement for MySQL.

Given the gut feeling I have about Oracle I have been looking at MariaDB every now and then already. Yesterday I had some free minutes and thought I'd give that claim a test run. I am using MacPorts, so installing MariaDB itself is easy enough:

sudo port install mariadb-server

But, what next? Even though MariaDB is a drop-in replacement, some things needed to be tweaked in my setup. First thing I came to think of, was my PHP configuration, so I replaced the three MySQL default socket settings in /opt/local/etc/php54/php.ini with the new value /opt/local/var/run/mariadb/mysqld.sock (in fact, only the mariadb in those lines is new).

Then I copied my existing database files from /opt/local/var/db/mysql5/ over to the MariaDB location /opt/local/var/db/mariadb/.

Note: By default MariaDB (at least in MacPorts) comes with skip-networking enabled in /opt/local/etc/mariadb/macports-default.cnf, which you may want to disable unless you are working exclusively with sockets.

Finally I started MariaDB after stopping MySQL:

sudo port unload mysql5-server
sudo port load mariadb-server

And there I had it: a working replacement for MySQL. The finishing touches included restarting Apache (so PHP picked up the changed default socket) and running

sudo mysql_upgrade -p

to adjust the databases, since this was not only a switch, but also an upgrade - from MySQL 5.1 to MariaDB 5.5.

Oh, and of course:

sudo port uninstall mysql5-server mysql5


Comments

  1. Gravatar

    Thanks Karsten, for testing!
    Another question raised while thinking about a general switch over to mariadb (i am with you about the gut feeling concerning oracle): Is it true, that the main reason about using innodb for e.g. the caching tables in typo3 is obsolete with the switch to mariadb, as in mariadb myisam is said to be enhanced by row-locking on write operations, instead of the former table-locking?
    thanks in advance,
    clemens

  2. Gravatar

    Update: I added a note about the skip-networking setting I had forgotten to mention…

  3. Gravatar

    Migrations work fine, as from the PHP side you "are using MySQL": the driver configured is still MySQL, and it's really pdo_mysql (or mysqlnd, mysqli, mysql) doing the heavy lifting.

  4. Gravatar

    Thanks for your first-hand testing; I also liked Maria DB for its promises (however never checked it).
    I assume Neos migrations run as-is? Are they recognized or will

    $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql")

    fail?

    Cheers!

Leave a reply

Karsten Dambekalns

Creative Code Engineer

Contact / Impressum