How to replace MySQL with MariaDB in 11.36+

UPDATE: As of cPanel & WHM 11.48 we now support MariaDB natively, and this guide no longer needs to be followed. Please read about that in the 11.48 release notes.

Important: This setup is considered to be unsupported by the cPanel/WHM team. Please note that once cPanel/WHM no longer maintains MySQL on your system it is on the Systems Administrator to manage and maintain any updates and maintenance on the database software.  We recommend only experienced systems administrators perform the above and we are not responsible for any possible data loss.
Important: This guide may or may not work if you are utilizing MySQL 5.6 as MariaDB currently only has 5.5 and 10.0 which is a port off of 5.5 with some of 5.6 ported into it. Proceed at your own risk.

Below you will find some steps on how to affectively stop cPanel/WHM from maintaining MySQL and begin utilizing MariaDB for any and all database activity on your server. MariaDB is “An enhanced, drop-in replacement for MySQL” (Source: https://mariadb.com/). The guide found below is based around utilizing the new RPM tools we provide in 11.36. Important Links MariaDB Versus MySQL Compatibility MariaDB Versus MySQL Features Documentation on the RPM system provided by cPanel & WHM Step 1: Backup existing MySQL data Make sure to save all existing data just in case there are any issues.

cp -Rf /var/lib/mysql /var/lib/mysql-old
mv /etc/my.cnf /etc/my.cnf-old

Step 2: Disable the targets so cPanel no longer handles MySQL updates The following will mark the versions of MySQL we distribute as uninstalled so they are no longer maintained by cPanel/WHM

/usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled
/usr/local/cpanel/scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled

Step 3: Remove existing MySQL RPM’s so theres a clean slate for MariaDB

Important: The below command will uninstall the MySQL RPM’s!
/usr/local/cpanel/scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55
[20130218.235953]    
[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!

Step 4: Create a yum repository for MariaDB

vi /etc/yum.repos.d/MariaDB.repo

place the following inside of it depending on the DISTRO and MySQL version (https://downloads.mariadb.org/mariadb/repositories/):

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/[version]/[osdistro]/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Replace [version] with the equivalent of the version of MySQL you are running. Replace [osdistro] with the operating system you are utilizing. Step 5: Remove php from the /etc/yum.conf file then run the following commands

yum install MariaDB-server MariaDB-client MariaDB-devel
/etc/init.d/mysql start
mysql_upgrade
/etc/init.d/mysql restart

Step 5: Add php back to the /etc/yum.conf file to ensure future php updates don’t get clobbered Final Step: Rebuild easyapache/php to ensure modules are intact/working

/usr/local/cpanel/scripts/easyapache --build

 

cPanel

The web hosting industry's most reliable management solution since 1997. With our first-class support and rich feature set, it's easy to see why our customers and partners make cPanel & WHM their hosting platform of choice. For more information, visit cPanel.net.

47 responses to “How to replace MySQL with MariaDB in 11.36+”

  1. Jesse says:

    @harijithrajasen:disqus I’ve actually updated it to not include any version or OS as this will vary depending on what you’re running and don’t want users to copy/paste the wrong content.

  2. Jesse says:

    @refica I’ve updated the article a bit and included some important bits at the top. MariaDB 5.10 is actually a port of 5.5 with some MySQL 5.6 pulled into it. I am not confident all instances of MySQL 5.6 -> MariaDB 5.10 will work so I’ve added disclaimers.

  3. Reficul says:

    I’m stuck on mysql_upgrade that give me

    [~]# mysql_upgrade

    Error: Server version (5.6.17-log) does not match with the version of

    the server (10.0.13-MariaDB) with which this program was built/distributed. You can

    use –skip-version-check to skip this check.

    FATAL ERROR: Upgrade failed

    Because I’ve mysql 5.6 I’ve added this command
    /scripts/update_local_rpm_versions –edit target_settings.MySQL56 uninstalled
    and
    /scripts/check_cpanel_rpms –fix –targets=MySQL50,MySQL51,MySQL55,MySQL56.
    and point the repo to the new 10.0 release. But something wrong here…
    What can I check?

  4. Morgan Feldon says:

    We’re running WHM/cPanel, thus we’re not a systems administrator. Needs to be step-by-step. Not step-by-almost-step.

  5. Joao Machado says:

    In CentOS, you may have to run “yum clean all” to remove the caches..

  6. Harijith Rajasen says:

    Please update the baseurl. The new baseurl is “http://yum.mariadb.org/5.5.38/centos6-amd64/”.

  7. Dan says:

    I installed MariaDB 10, which doesnt operate as well as 5.5 for me. I rolled back to mySQL 5.5 and wanted to move to MariaDB 5.5 but even with changing the repo and starting from fresh the system still wants to download version 10.

    Is there anyway for me to force 5.5 install?

    Cheers
    Dan

  8. Feanor says:

    That’s amazing guide! Everything works perfect!
    Just replace baseurl = http://yum.mariadb.org/5.5.29/centos6-amd64/ with new http://yum.mariadb.org/10.0.11/centos6-amd64/, that’s all

  9. Gino says:

    It is correct… when compiling with easyapache:
    — Begin dryrun test ‘mysql compilation test’ —

    /cpmysql.c:4: warning: return type defaults to ‘int’

    /cpmysql.c: In function ‘main’:

    /cpmysql.c:6: warning: control reaches end of non-void function

    /usr/bin/ld: skipping incompatible /usr/lib/libmysqlclient.a when searching for -lmysqlclient

    /usr/bin/ld: skipping incompatible
    /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../libmysqlclient.a when
    searching for -lmysqlclient

    /usr/bin/ld: skipping incompatible /usr/lib/libmysqlclient.a when searching for -lmysqlclient

    /usr/bin/ld: cannot find -lmysqlclient

    collect2: ld returned 1 exit status

    Can’t exec “/cpmysql”: No such file or directory at /var/cpanel/perl/easy/Cpanel/Easy/Utils/MySQL.pm line 102.

    Use of uninitialized value $test in string eq at /var/cpanel/perl/easy/Cpanel/Easy/Utils/MySQL.pm line 108.

    dryrun test ‘mysql compilation test’ did not return true

    !! Dry run failed for ‘Cpanel::Easy::PHP5::Mysql’ skipping option !!

  10. Gavin Schumaker says:

    Given that Google has announced that it’s migrating away from MySQL to MariaDB, it’s high time for cPanel to jump on the bandwagon and migrate to MariaDB – especially since Oracle is not exactly rushing out new features or even bug fixes.

    MariahDB is really cooking along with new features for very high performance – including NoSQL support using different database engines, and much better (i.e., speedier) master/slave replication) and is of course headed up by Monty Widenius, one of the original creators of MySQL

    I’ve been a fan of MySQL since the late nineties, but with it’s acquisition by Oracle, it’s heading downhill fast. As a long time sysadmin and web host provider, I’d much rather have MariahDB under the cPanel hood going forward.

  11. […] These instructions can also be used to install MariaDB!  For more info on this, see cPanel’s blog. […]

  12. Jesse says:

    @laztrix:disqus There is no definitive timeframe on when/if this will be supported – following the features page on this will give the most up to date information on where it’s at with our development feature teams.

  13. laztrix says:

    When will cpanel offically support MariaDB? I’ve been reading all the “we’re investigating” messages posted by cpanel officials but years has passed, nothing! Why are we being stalled?

  14. Jesse says:

    @rawiz:disqus cPanel does not depend on system perl any longer, so you can remove the perl exclude permanently as we no longer manage system perl. New installs will no longer have it in the excludes file.

  15. Jesse says:

    @jimlongo:disqus, /etc/yum.repos.d should already exist on CentOS systems.

    Please note the guide is meant for a systems administrator who’s already familiar with these files, but good note about it needing to be removed from excludes (although it is the only place that has it).

    I only showed the mirror in the comment box as an example, in my note above the step it does say it depends on the distribution.

    I am glad you got things working!

  16. SEO_SEM_Stuff says:

    I can do this for you… my skype is alex_nadtoka

  17. in #4, i need to temporary remove perl* too from yum.conf, because instalation need dependency with perl-DBI

  18. jimlongo says:

    Tried this 3 times before I got it right (11.38.2) . . . a couple of comments.
    You might need to create the directory /etc/yum.repos.d before you can do
    #4 pico /etc/yum.repos.d/MariaDB.repo

    #5 remove php from /etc/yum.conf is not totally clear, I assume you mean remove it from the line “exclude = … php* …

    in number 5 the text added to the file /etc/yum.repos.d/MariaDB.repos is critical that you have this right, I had 64 bit instead of 32 bit Centos 5, and it wouldn’t allow yum to install the packages, kept getting an error “No package available”.

    Thanks.

  19. Uncheck “use MySQL of the system” in EasyApache and you should be ready to go. I’ve been using MariaDB in several cPanel boxes for months now, with no issues of any kind.

  20. I didn’t mean that. It was late. I saw this. Ooops.:
    /scripts/easyapache –build
    I can run easy apache but should I uncheck mysql while building easy apache or does it do the same thing as mariadb? It’s alright to check it? I had dependency errors while trying to install it in the first place.

  21. Nicki says:

    Nice guide! I have been eyeing MariaDB for a while and had wondered how easily it could be replaced on a cPanel box. Thank you for sharing this! ^_^

  22. Jesse says:

    Hello @iBotPeaches:disqus, I’m glad everything worked out for you!

  23. Jesse says:

    Hey @ralphchastain:disqus, yes you can still run easyapache – since you’re utilizing yum to install mariadb, it will continue to utilize this.

  24. Jordan says:

    Hi is there anyone up for helping me to migrate from MySQL to MariaDB. I’ll pay him/her for the time 🙂
    I do not know anything about server and I’m not a techie guy. I know this can be easily done, but I cannot afford any mistake at all.

  25. Can we run easy apache or will it screw up the server?

  26. iBotPeaches says:

    I just bite the bullet and did on 11.38. No problems, worked great 🙂

  27. Asterisk says:

    Oh yeah, I got that anthem down. Haha! Thanks again.

  28. Jesse says:

    Hey @yanniskarampelas:disqus, No problem!

  29. Jesse says:

    Hey Asterisk, the switch should be seamless, however, backups and precaution should always be taken if you’re doing it on a live and active server.

  30. Asterisk says:

    Thanks for the response, Jesse. I’m not terribly concerned about the guide, but it’s nice to have the information there. As the server I’m looking to do this on has a couple of live elements(like our documentation).

  31. Yannis Karampelas says:

    thanks Jesse!

  32. Jesse says:

    Hey Asterisk, you can revert back to MySQL by removing the MariaDB RPM’s and then running the following:

    /scripts/update_local_rpm_versions –edit target_settings.MySQL55 installed

    /scripts/check_cpanel_rpms –fix

    Nothing in the above guide should have a possibility of wrecking your server.

  33. Jesse says:

    Hey Yannis Karampelas, you essentially need to uninstall the MariaDB RPM’s and then run:

    /scripts/update_local_rpm_versions –edit target_settings.MySQL55 installed

    /scripts/check_cpanel_rpms –fix

  34. Jesse says:

    Hey @janiosarmento:disqus, please note that this tutorial is basically just for switching out the MySQL with MariaDB – any modules after this is something extra that will need to be done. Unless newer versions of MariaDB have been released since the posting of this article that don’t include this stuff, it should all work after the instructions above.

  35. Asterisk says:

    Is there a means to rollback effectively or restore mysql in the event that things go sideways? I noticed someone mentioned wrecking their server because of what seems like compatibility issues?

  36. Yannis Karampelas says:

    How do we restore mysql if needed?

  37. I tried this tutorial today, and I put down my server.

    One should be advised that recent versions of MariaDB DO NOT include some client libraries needed to run PHP (libmysqlclient.so.18, for example). It seems to me this tutorial could work for CentOS 6, but for CentOS 6 the server will not be usable.

    Or, otherwise, I missed some important detail, but I don’t think so.

  38. Brian Oates says:

    Compared to the forums, the blog is a more direct and less cluttered way to compile together the various (un)supported guides that cPanel staff has put together. Despite that this particular guide is unsupported, cPanel is passionate at doing everything well. If it’s something our customers may try anyway in spite of MariaDB not having official support, there’s a lot of us here that like to put our knowledge and experience to work and come up with something that should at least reduce any complications experienced when those customers try it

    Something I also want to stress is that these articles do not detract from or lessen the time spent developing and improving our software.

  39. Jesse says:

    Hey @google-558abd4c43282f502545986422fcfc01:disqus, yes, that is correct. I’ve included this step in the guide. It shouldn’t give any issues but it will ensure future php updates don’t clobber the updates we provide. Thanks for pointing that out!

  40. Sam says:

    Would lik to know the answer to this.

  41. Connor Tumbleson says:

    Once we remove php from the exclusion yum.conf, do we add it back after we’ve completed the re-build of apache?

  42. Jesse says:

    @facebook-1403081351:disqus – There is a feature request submitted with approximately 57 votes currently on our features page: http://features.cpanel.net/responses/as-a-server-administrator-i-want-mariadb-support-so-that-i-can-accomodate-both-innodb-and-noninnodb-users — You may want to go submit your vote there as majority of the features we pull from are submitted there. 🙂

  43. MariaDB would be integrated into WHM/cPanel in the near future?

  44. I don’t understand why cpanel would spend even one second writing a blog post on the official cpanel blog about how to install replace core cpanel supported software with unsupported software.
    This seems like something more appropriate for the forums somewhere…

Leave a Reply