This guide walks you through safely upgrading MySQL 5.x to 8.0 using CloudLinux’s MySQL Governor
🔍 MySQL Version Options for Governor
/usr/share/lve/dbgovernor/mysqlgovernor.py --mysql-version=mysql80
MySQL Governor supports various MySQL versions. Here’s how to set the version:
| Version Value | MySQL Version |
|—————|—————-|
| `auto` | Default (depends on OS/cPanel) |
| `mysql51` | MySQL 5.1 |
| `mysql55` | MySQL 5.5 |
| `mysql56` | MySQL 5.6 |
| `mysql57` | MySQL 5.7 |
| `mysql80` | MySQL 8.0 (requires MySQL Governor 1.2-37+) |
✅ Step-by-Step Upgrade Process
🔒 Create Backup Directory
mkdir -p /backup/mysql_upgrade/sql_exports
mkdir -p creates the directory and subdirectory at once.
This will store SQL dumps of your current databases for rollback if needed.
💾 Export All Databases
Navigates into the export folder.
cd /backup/mysql_upgrade/sql_exports
Export all databases
for i in $(mysql -e 'show databases;' |grep -v 'Database\|information_schema\|performance_schema'); do echo $i; mysqldump --single-transaction $i > $i.sql; done;
– mysql -e show databases;’`: Lists all databases.
– grep -v : Filters out system databases.
– mysqldump –single-transaction : Safely exports each database to a `.sql` file.
– > $i.sql : Saves each database to its own `.sql` file.
🛑Stop MySQL and Backup Configs
Stops MySQL service safely before upgrade.
whmapi1 --output=jsonpretty configureservice service='mysql' enabled=0
Does the following:
- Tells cPanel/WHM to disable the MySQL service from being started or monitored by its internal systems (like chkservd).
- It modifies WHM’s service manager settings so that:
- MySQL does not start automatically on reboot.
- WHM won’t attempt to restart it if it stops.
cp -prf /etc/my.cnf /backup/mysql_upgrade/
cp -prf: Copies the MySQL config file (my.cnf) with:
-p : Preserves timestamps.
-r : Recursively (if folder).
-f : Forces overwrite.
Copies the entire MySQL data directory for emergency restore if needed.
cp -prvf /var/lib/mysql /backup/mysql_upgrade/
🧱 List and Backup Installed MySQL RPMs
rpm -qa | grep -i mysql | grep 5.7
Lists all currently installed MySQL-related RPMs, specifically version 5.7.
mkdir -p /backup/mysql_upgrade/rpm_exports cd /backup/mysql_upgrade/rpm_exports
Prepares directory to store rebuilt RPMs.
for i in $(rpm -qa | grep -i mysql | grep 5.7); do echo $i; rpmrebuild -n $i; done;
Rebuilds installed MySQL RPM packages using `rpmrebuild`.
-n: Build RPMs in non-interactive mode.
cp -prf /root/rpmbuild/RPMS/x86_64/* /backup/mysql_upgrade/rpm_exports/
Copies the newly rebuilt RPMs to your backup folder.
Useful if you ever need to revert.
⬆️ Upgrade to MySQL 8.0 via Governor
Sets MySQL Governor to use version 8.0.
/usr/share/lve/dbgovernor/mysqlgovernor.py --mysql-version=mysql80
Start MySQL and installed
systemctl start mysql
/usr/share/lve/dbgovernor/mysqlgovernor.py --install
– Installs the new MySQL version and applies Governor’s integration.
🚀 Start MySQL and Upgrade System Tables
systemctl start mysql
Starts the upgraded MySQL service.
mysql_upgrade
Updates internal system tables and checks for any incompatibilities or issues post-upgrade.
🧠 Final Tips
– Double-check that all apps are compatible with MySQL 8.0.
– Consider testing this entire process in a staging environment.
– Keep your `/backup/mysql_upgrade` folder safe until you’re confident everything works.