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
1 |
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.
1 |
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
1 |
whmapi1 configureservice service=mysql enabled=1 monitored=0 |
Stop MySQL
1 |
/scripts/restartsrv_mysql --stop |
Take a copy of MySQL data directory
1 2 |
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
1 2 3 4 5 6 7 |
root@server20 [~]# mysql -e "show variables like 'datadir';" +---------------+-----------------+ | Variable_name | Value | +---------------+-----------------+ | datadir | /var/lib/mysql/ | +---------------+-----------------+ root@server20 [~]# |
Start MySQL
1 |
/scripts/restartsrv_mysql |
Enable Monitoring
1 |
whmapi1 configureservice service=mysql enabled=1 monitored=1 |
Upgrade MySQL/MariaDB using WHM
Login to WHM as user root. Go to
1 |
WHM > SQL Services > MySQL/MariaDB Upgrade |
You can also use the search box in WHM, and search for “MariaDB upgrade”.
On this page, select the MySQL or MariaDB version you need. Then click on the “Continue” button.
It will show some warnings related to MySQL/MariaDB changes. You need to check all check boxes, then click on the “Continue” button.
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