How to Upgrade MySQL/MariaDB in WHM cPanel Server

cPanel server supports MySQL and MariaDB. In most cases MySQL and MariaDB are compatible, you will be fine with either of them.

Find current MySQL version

Before you upgrade, find out what version of MySQL or MariaDB you are using with the command

mysql --version

Check MySQL version

In this server, we have MariaDB 10.3.37.

You can note down the rpm files, so you know the exact RPMs names in case you need to revert back.

rpm -qa | egrep -i "(mysql|mariadb)" | grep -v php | grep -v alt

Backup MySQL database

Before upgrading MySQL take a backup of the MySQL folder.

Disable Monitoring for MySQL/MariaDB so it won’t auto start

whmapi1 configureservice service=mysql enabled=1 monitored=0

Stop MySQL

/scripts/restartsrv_mysql --stop

Take a copy of MySQL data directory

mkdir -p ~/mysql-backup
cp -r /var/lib/mysql/ ~/mysql-backup/

If you use a non-default MySQL data directory location, you may need to change the path /var/lib/mysql.

You can find the MySQL data directory with the command

root@server20 [~]# mysql -e "show variables like 'datadir';"
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+
root@server20 [~]# 

Start MySQL

/scripts/restartsrv_mysql

Enable Monitoring

whmapi1 configureservice service=mysql enabled=1 monitored=1

Upgrade MySQL/MariaDB using WHM

Login to WHM as user root. Go to

WHM > SQL Services > MySQL/MariaDB Upgrade

You can also use the search box in WHM, and search for “MariaDB upgrade”.

WHM MySQL/MaraDB upgrade

On this page, select the MySQL or MariaDB version you need. Then click on the “Continue” button.

MariaDB upgrade warning

It will show some warnings related to MySQL/MariaDB changes. You need to check all check boxes, then click on the “Continue” button.

MariaDB upgrade method

On this page, you get 2 options “Unattended Upgrade” and “Interactive Upgrade”. You can select any of it and click the “Continue” button to do the upgrade.

Back to cPanel Server

Comments

Leave a Reply

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