MariaDB is a relational database management system (rDBMS) that was forked from MySQL, the de-facto database for most popular open-source web platform and apps. MariaDB is intended as the enhanced drop-in replacement for MySQL, so that developers and database administrators can switch to MariaDB easily due to high compatibility with MySQL, library binary equivalency and exact matching with MySQL APIs and commands.

This tutorial shows the step-by-step guide on upgrading and converting from MySQL version 5.1 firstly to MariaDB version 5.5, and then subsequently to MariaDB 10.0, in CentOS 6.6 system. The procedure should works on most Red Hat Enterprise Linux (RHEL), CentOS, Fedora, Scientific Linux and similar distributions version 5, 6 and 7.

Part 1 – Install and Upgrade MySQL 5.1 to MariaDB 5.5

  1. Make a backup of MySQL databases:
    mysqldump --all-databases > /tmp/backup.sql

    Backup the MySQL configuration file:

    cp /etc/my.cnf /etc/my.cnf.bak

    You may also want to backup the complete directory of databases, i.g. /var/lib/mysql. In this case, stop the MySQL daemon with service mysql stop then copy: cp -R /var/lib/mysql /tmp/mysql_lib_backup.

  2. Ensure that all software packages are up-to-date before upgrading:
    yum update
  3. Visit MariaDB repository configuration generator to setup a MariaDB 5.5 repo by selecting your distro and release. MariaDB Repo Configuration Generator Create a file named MariaDB.repo (or any name you prefer) in /etc/yum.repos.d directory, and paste the custom MariaDB YUM repository entry for CentOS generated into it.
    vi /etc/yum.repos.d/MariaDB.repo

    For CentOS 6.6, the content of /etc/yum.repos.d/MariaDB.repo is:

    # MariaDB 5.5 CentOS repository list - created 2015-01-01 22:33 UTC
    name = MariaDB
    baseurl =
  4. Clean the repository cache information:
    yum clean all
  5. Stop the MySQL service if it's still running:
    service mysqld stop
    Depending on your distro, the MySQL service name may be just “mysql” instead of “mysqld”.
  6. Uninstall and remove MySQL 5.1:
    yum remove mysql mysql-server
    Your system may have “mysql-libs” and “mysql-devel” packages installed. If they’re not been removed as part of dependencies, use yum remove mysql-libs mysql-devel to uninstall them too.

    Some errors that may be encountered if old version of MySQL still in existent include:

    Transaction Check Error:

    file /usr/share/mysql/english/errmsg.sys from install of MariaDB-server-10.0.9-1.el6.i686 conflicts with file from package mysql-libs-5.5.36-1.el6.remi.x86_64

    Sometimes yum will include a lot of still needed dependencies to be removed with MySQL. In this case, use the rpm -e –nodeps package_name to remove just the individual package without affecting any dependencies. For example, rpm -e –nodeps mysql.
  7. Install MariaDB 5.5:
    yum install mysql-server

    Install MariaDB 5.5

  8. When installation is completed, start the MariaDB database service:
    service mysql start
  9. Run the MariaDB upgrade script:
    If you encounter the following error, use mysql_upgrade -p then enter database root password.

    ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)

  10. Verify that the MySQL is now MariaDB 5.5 by logging into the database system using command-line client:

    The output should indicates MariaDB:

    Welcome to the MariaDB monitor. Commands end with ; or \g.
    Your MariaDB connection id is 12
    Server version: 5.5.41-MariaDB MariaDB Server

    Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

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

    MariaDB [(none)]>

If you want to use MariaDB 10, you can continue to Part 2 - Upgrade MySQL/MariaDB 5.5 to MariaDB 10.0.