MariaDB: Replaces Mysql, gives you more (without effort!)

Mysql. It seems these days everybody doing something in the IT branch has used it, or still does. However, there are some problems: you only get the fun stuff (like clustering etc) if you pay big time, its development is stalling (more and more core developers are leaving), a seemingly evil company is running it[/url], and last but not least, the community is being excluded.

There is a solution though. It’s called MariaDB. MariaDB is a fork of Mysql, and was started by Michael Widenius (aka Monty), the original author of Mysql. MariaDB is a project that actually is as open to the community as can be, releases all its code under a truly open license like the BSD/MIT license whenever possible and is able to add new functionality at a much faster pace than Oracle does. Last but not least, MariaDB is 100% backwards compatible with Mysql, and therefore can be used as a drop-in replacement.

[more]
I assume the first thing you want to do now is replace Mysql on your server/pc with Mariadb, but if you want to read/know more about MariaDb first, you can always check out the source code, see its launchpad page, checkout the contribute page, join all mariadb experts on Freenode (irc) or just leave a comment below.

So, besides assuming that you want to replace your installation of Mysql with MariaDB, I’ll make some more assumptions. I assume that…
[list]

  • You backed up the universe & everything around it

  • Mysql was running fine before upgrading

  • Mysql’s version is either 5.0 or 5.1

  • You’re running Centos 5.5 (chances are that on different distros this will work just as well)

  • [/list]

    Installing it is relatively simple, we stop & remove mysql, we download & extract mariadb, install another version of the init script:

    # /etc/init.d/mysqld stop
    # yum remove mysql
    # cd /usr/local/
    # wget http://askmonty.org/downloads/r/http://mirrors.supportex.net/mariadb/mariadb-5.2.4/kvm-bintar-hardy-amd64/mariadb-5.2.4-Linux-x86_64.tar.gz
    # tar xvf mariadb-5.2.4-Linux-x86_64.tar.gz
    # ln -s mariadb-5.2.4-Linux-x86_64 mysql
    # cd mysql
    # ./scripts/mysql_install_db --user=mysql
    # cp support-files/mysql.server /etc/init.d/mysqld
    # ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
    # chown -R root .
    # chown -R mysql data

    Now edit /etc/init.d/mysqld, and replace the datadir and basedir directives with:

    basedir=/usr/local/mysql/
    datadir=/var/lib/mysql/

    And then start MariaDb: /etc/init.d/mysqld start

    Now there are a few things left. First of all, you probably need to upgrade your mysql tables, for that you need the password of the administrative user. If you’re using DirectAdmin you can find this in /usr/local/directadmin/conf/mysql.conf. If you’re not running DirectAdmin, you probably know the password of the root account (or another account with all rights required) yourself.

    After having found or thought of your password, upgrade the tables MariaDB uses internally. Please note, without this step everything will probably work just as well, but eventually you supposedly will run into problems, we restart MariaDB afterwards (if your root account isn’t called ‘da_admin’ you need to replace that with the actual username):

    ./bin/mysql_upgrade -u da_admin -p
    /etc/init.d/mysqld restart

    If there are still any problems MariaDb will tell you about them in either /var/log/messages or /var/lib/mysql/yourhostname.tld.err

    Finally, if using DirectAdmin, make sure to set mysql_inst to ‘no’ in /usr/local/directadmin/custombuild/options.conf, to ensure that mysql won’t be reinstalled with a next upgrade.