Over the last couple of days I've had to install cPanel & WHM a few times, each time forgetting to setup a /root/cpanel_profile/cpanel.config with my preferred database type/version. Thankfully since these were new installs of cPanel & WHM I had no databases in place so making the transition from the default install of MySQL to MariaDB 10.5 was easy.

First we need to remove MySQL 8.0. All of the following commands should be run as the root user.

dnf -y remove mysql-community-*

Next we need to remove the MySQL data directory. You can also rename it, but since there's nothing in there we need I opted to just remove it out right.

rm -rf /var/lib/mysql

Now we need to update the version of MySQL or in our case MariaDB we want on our server in the cPanel configuration file. You can either use your favorite command line editor to edit the /var/cpanel/cpanel.config file or use the following command.

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

Next we'll use a nifty API command to install MariaDB!

whmapi1 start_background_mysql_upgrade version=10.5

If you'd like to watch the progress of the install, you can run the following. Please note, the command won't be exactly as shown below because the timestamp on the log file (the filename of the log) will be different for everyone.

tail -f /var/cpanel/logs/mysql_upgrade.20211213-12345/unattended_background_upgrade.log

It took about 5 minutes or so for the install to complete on my system. Once this is done, you should be able to type in mysql -V and see output similar to:

mysql  Ver 15.1 Distrib 10.5.13-MariaDB, for Linux (x86_64) using readline 5.1

Resources