You can do this with relative ease, using cPanel and CloudLinux’s internal scripts.

Step one, set the version of MySQL you want installed using cPanel’s RPM version script. In our example we’re installing MySQL 5.5.

/scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled
/scripts/update_local_rpm_versions --edit target_settings.MySQL55 installed
/scripts/update_local_rpm_versions --edit target_settings.MySQL56 uninstalled
/usr/share/lve/dbgovernor/db-select-mysql --mysql-version=mysql55

Then, if you run the cPanel RPM script asking it to look for problems, you’ll see something like this:

/scripts/check_cpanel_rpms --long-list --list-only
[20141227.195928]
[20141227.195928] Problems were detected with cPanel-provided files which are RPM controlled.
[20141227.195928] If you did not make these changes intentionally, you can correct them by running:
[20141227.195928]
[20141227.195928] > /usr/local/cpanel/scripts/check_cpanel_rpms --fix
[20141227.195928] The following RPMs are missing from your system:
[20141227.195928] MySQL55-client-5.5.40-1.cp1136
[20141227.195928] MySQL55-devel-5.5.40-1.cp1136
[20141227.195928] MySQL55-server-5.5.40-1.cp1136
[20141227.195928] MySQL55-shared-5.5.40-1.cp1136
[20141227.195928] MySQL55-test-5.5.40-1.cp1136
[20141227.195928] compat-MySQL50-shared-5.0.96-4.cp1136
[20141227.195928] compat-MySQL51-shared-5.1.73-4.cp1136

Before you go any further, I recommend making an archive backup of all of your existing MySQL data. Assuming your /var/ partition can hold your backup, you can use this command:

cp -a /var/lib/mysql /var/lib/mysql.bak

The next step is to remove the MariaDB rpms. Use this command to view all installed RPMs that use MariaDB in the name:

rpm -qa | grep MariaDB

If you feel confident that all of the RPMs listed are the ones you want to remove, you can use this command to quickly remove them:

rpm -qa | grep MariaDB | xargs rpm -e

Then confirm they were removed with this command again:

rpm -qa | grep MariaDB

Then, ask cPanel to install your chosen version of MySQL with this command:

/scripts/check_cpanel_rpms --fix

Once that completes, you shouldn’t see any other problems! If you do see any problems related to the version of MySQL that the server has installed, try running a cPanel update with this command:

/scripts/upcp

That should take care of any lingering errors you might encounter.

Happy MySQLing!