Upgrade MySQL 8 to MariaDB in cPanel

I installed cPanel & WHM multiple times, and on each occasion, I forgot to set up a /root/cpanel_profile/cpanel.config file with my preferred database type and version. Luckily, since these were new installations with no existing databases, transitioning from the default MySQL to MariaDB 10 was straightforward. I do not recommend doing this on a server that is already housing multiple Databases, as it will most likely render them useless. ONLY USE THIS METHOD ON A FRESHLY INSTALLED SERVER. I take no responsibility if you do otherwise.

To begin, we need to uninstall MySQL 8.0. All the following commands should be executed as the root user:

dnf -y remove mysql-community-*

Next, we should remove the MySQL data directory. Alternatively, you can rename it, but since there’s no data to preserve, I chose to delete it outright:

rm -rf /var/lib/mysql

Now, let’s update the MySQL version (in our case, MariaDB) we want to use on our server in the cPanel configuration file. You can either use your preferred command line editor to modify the /var/cpanel/cpanel.config file or use the following command:

sed -i 's/mysql-version=8.0/mysql-version=10.6/g' /var/cpanel/cpanel.config

Next, we’ll use a convenient API command to initiate the installation of MariaDB:

whmapi1 start_background_mysql_upgrade version=10.5

To Monitor the installation head over to /var/cpanel/logs/ and tail the log file

tail -f /var/cpanel/logs/mysql_upgrade.xxxx/unattended_background_upgrade.log

The installation took around 2 min. The server has since ran for 3 months with multiple new accounts and all works as it should.
I am unsure why cPanel does not mention this anywhere.

Facebooktwitterredditpinterestlinkedinmail

1 thought on “Upgrade MySQL 8 to MariaDB in cPanel”

Leave a Comment

Your email address will not be published.