How to replace MySQL with MariaDB on a cPanel server

MariaDB is an enhanced drop-in replacement for MySQL. MySQL 5.1 is compatible with MariaDB 5.1, 5.2 and 5.3. MySQL 5.5 is compatible with MariaDB 5.5.

Features of MariaDB
>> Data and table definition files (.frm) are binary compatible.
>> All client APIs, protocols and struct are identical
>> All filenames, binaries, paths, ports, sockets etc should be the same.
>> All MySQL connectors (PHP, Perl, Python, Java, .NET, MyODBC, Ruby, MySQL C connector) works unchanged with MariaDB.
>> mysql-client package also works with MariaDB server
>> The shared client-library is binary compatible with MySQL’s client library

This indicates that we can just uninstall MySQL and install MariaDB.

Steps to replace MySQL with MariaDB

1. To be secure with our current data, make sure to take a backup:

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

2. Disable the targets so that cPanel won’t handle MySQL updates

# /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

3. Remove all the MySQL RPMs from the server

# /scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55

The above command will uninstall all the MySQL RPMs from the server.

4. Create Yum repository for MariaDB

Create a file “MariaDB.repo”.

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

Place the following in the newly created repo file depending on the DISTRO ( ):

name = MariaDB
baseurl =

5. Remove php from “exclude” list in /etc/yum.conf

6. Install MariaDB-sever, MariaDB-client, MariaDB-devel

# yum install MariaDB-server MariaDB-client MariaDB-devel

7. Start MySQL

# /etc/init.d/mysql start

8. Then, run mysql_upgrade

# mysql_upgrade

9. Restart MySQL

# /etc/init.d/mysql restart

10. Add PHP back to the /etc/yum.conf file in “exclude” list

11. Recompile Apache with PHP

# /scripts/easyapache --build

Done!! You can check it by executing the command ‘mysql -V’

# mysql -V
mysql  Ver 15.1 Distrib 5.5.34-MariaDB, for Linux (x86_64) using readline 5.1

That’s it 🙂

How to replace MySQL with PerconaDB on a cPanel server
How to enable remote MySQL for an IP address on a cPanel server via CSF
How to upgrade MySQL from 5.1 to 5.5 in a cPanel server – command line option
How to allow mysql client to access remote mysql databases

Post navigation

Arunlal Ashok

Cloud Infrastructure / DevOps Engineer. I'm dealing Linux servers since 2012. I started this blog to share and discuss my ideas.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team

2 thoughts on “How to replace MySQL with MariaDB on a cPanel server

Leave a Reply

Your email address will not be published. Required fields are marked *