How to Replace MySQL with MariaDB

How to Replace MySQL with MariaDB




  • We strongly recommend that you use WHM’s MySQL or MariaDB Upgrade interface (Home >> Software >> MariaDB/MySQL Upgrade) to replace the cPanel-provided and cPanel-managed MySQL installation with MariaDB. To do this, you must upgrade your server to cPanel & WHM version 11.48 or later.
  • This document describes an unsupported workaround that is not guaranteed to work in the future.
    • After a system administrator performs these steps on a server, it is the system administrator’s responsibility to manage and maintain the server’s database software.
    • We recommend that only experienced system administrators attempt to perform these steps.
    • We are not responsible for any data loss that an attempt to perform these steps causes.

Replace MySQL with MariaDB

To replace the cPanel-provided MySQL installation with MariaDB, perform the following steps:

  1. Run the following commands to back up your existing MySQL data:
    cp -Rf /var/lib/mysql /var/lib/mysql-old
    mv /etc/my.cnf /etc/my.cnf-old
  2. Run the following commands to disable the MySQL RPM targets. cPanel & WHM will no longer handle MySQL updates, and the rpm.versions system will mark the associated MySQL RPMs as uninstalled.
    /scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled
    /scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled
    /scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled 
    /scripts/update_local_rpm_versions --edit target_settings.MySQL56 uninstalled
  3. Run the following command to remove the existing MySQL RPMs from your server. This will leave a clean slate for the MariaDB installation.
    /scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55,MySQL56

    You will see a message that is similar to the following output:

    [20130218.235953]   The following RPMs are unneeded on your system and should be uninstalled:
    [20130218.235953]   MySQL51-devel.5.1.68-1.cp1136
    [20130218.235953]   MySQL51-test.5.1.68-1.cp1136
    [20130218.235953]   MySQL51-shared.5.1.68-1.cp1136
    [20130218.235953]   MySQL51-client.5.1.68-1.cp1136
    [20130218.235953]   MySQL51-server.5.1.68-1.cp1136
    [20130218.235953]   Removing 0 broken rpms: 
    [20130218.235953]   rpm: no packages given for erase
    [20130218.235953]   No new RPMS needed for install
    [20130218.235953]   Uninstalling unneeded rpms: MySQL51-devel MySQL51-test MySQL51-shared MySQL51-client MySQL51-server
    [20130219.000004]   Shutting down MySQL........ SUCCESS!
  4. Run the following command to create a yum repository for MariaDB:
    vi /etc/yum.repos.d/MariaDB.repo
  5. Enter the following contents for the /etc/yum.repos.d/MariaDB.repo file:
    name = MariaDB
    baseurl =

    Where VERSION represents the currently-available version of MariaDB. For example, if the current version is 5.5.40, then the MariaDB.repo file would contain:

    name = MariaDB
    baseurl =
  6. Use your preferred text editor to open the /etc/yum.conf file and remove php* and mysql* from the exclude line. The exclude line in your /etc/yum.conf file may appear similar to the following example:
    exclude=bind-chroot courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* mysql* nsd* php* proftpd* pure-ftpd* ruby* spamassassin* squirrelmail*
  7. Run the following commands to install MariaDB and restart the appropriate services: 
    yum install MariaDB-server MariaDB-client MariaDB-devel php-mysql
    /etc/init.d/mysql start
    /etc/init.d/mysql restart
  8. Run the following command to rebuild EasyApache’s PHP to ensure that all PHP modules remain intact:
    /scripts/easyapache --build

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.