Databases 15 min read

Step‑by‑Step In‑Place Upgrade Guide for MySQL 8.0 (MGR Cluster)

This article provides a comprehensive, step‑by‑step guide for performing an in‑place upgrade of MySQL 8.0 (including MGR clusters) from earlier versions, covering pre‑upgrade checks, backup procedures, configuration changes, data dictionary upgrade, server upgrade, verification, rollback, and common pitfalls.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Step‑by‑Step In‑Place Upgrade Guide for MySQL 8.0 (MGR Cluster)

1 Why Upgrade?

Because MySQL versions prior to 8.0.24 contain many bugs; see the MySQL 8.0 Release Notes. The latest version at the time of writing is 8.0.34, released on July 18, 2023.

2 What DBA and Business Teams Need to Do Before Upgrade?

For a minor version upgrade (e.g., 8.0.x to 8.0.z) you can upgrade directly. After the MySQL service starts, check the error log for parameter name changes or deprecations and update the configuration file accordingly.

If you have never upgraded before or need a major upgrade from MySQL 5.7 to 8.0, follow the official upgrade documentation and perform the following initial checks:

Backup data (only GA is supported).

mysqlcheck -u root -p --all-databases --check-upgrade

util.checkForServerUpgrade()

3 Upgrade Strategy

Prerequisite: All upgrade checks for MySQL 8.0 have been completed.

The official upgrade process consists of two steps:

Step 1: Data dictionary upgrade.

Step 2: Server upgrade.

Before MySQL 8.0.16, the upgrade was performed with mysql_upgrade . Starting from 8.0.16, mysqld can upgrade automatically.

Upgrade MGR secondary nodes sequentially.

Switch to the new primary node.

Finally upgrade the old primary node.

If a MySQL Router is used, business impact is minimal, but you should still notify the business side because the application may need to be restarted for verification. Requesting a change window is the optimal solution.

4 Detailed Upgrade Steps

Environment: Upgrade from MySQL 8.0.27 to MySQL 8.0.33. When upgrading a replica, set skip_slave_start=1 or skip_replica_start=1 .

4.1 Pre‑Upgrade Checks

# The following three methods are all valid
mysqlsh root@localhost:3306 -e "util.checkForServerUpgrade();"

MySQL JS > util.checkForServerUpgrade("[email protected]:3306")

util.checkForServerUpgrade("[email protected]:3306", {"targetVersion":"8.0.33","outputFormat":"JSON","configPath":"/data/mysql/3306/my.cnf.3306"})[Check specific version]

# Auxiliary check
mysqlcheck -uadmin -p -h127.0.0.1 --all-databases --check-upgrade

4.2 Backup Data and Configuration Files

Logical or physical backup.

cp -rp /data/mysql/data/3306   /data/mysql/data/3306_bak   # optional backup of data directory
cp my.cnf bak_8.0.xx_my.cnf

4.3 Stop Service and Prepare basedir

Check table status before shutting down.

select * from information_schema.tables where TABLE_COMMENT like "%repair%";

Safely stop the service.

set global innodb_fast_shutdown = 0;  # flush data to disk, disable fast shutdown
shutdown;

# Verify service stopped
ps -ef | grep mysql

If this is a replica (no replication lag):

show slave status\G
stop slave;

Backup data files if disk space permits.

cp -rp /data/mysql/data/3366 /data/mysql/data/3366_bak_1013

Prepare the basedir – create a symbolic link or replace directly.

show variables like "%basedir%";  # or which mysql

# Backup original basedir
mv mysql_Basedir mysql_Basedir_bak
chown -R mysql:mysql mysql-8.0.33-linux-glibc2.12-x86_64

# Create symlink to new package
ln -s mysql-8.0.xx-new-version-linux-glibc2.12-x86_64 mysql_Basedir
chown -R mysql:mysql mysql_Basedir

# Example
ln -s mysql-8.0.33-linux-glibc2.12-x86_64 base
lrwxrwxrwx 1 mysql mysql 35 Sep 7 16:14 base -> mysql-8.0.33-linux-glibc2.12-x86_64

# Optional: update PATH
export PATH=$PATH:/usr/local/mysql/bin

# Or rename old directory
mv mysql mysql_8.0.xx
mv mysql-8.0.xx-linux-glibc2.12-x86_64 mysql

4.4 Start Database

Starting the service performs both the data dictionary upgrade and the server upgrade.

Record the original startup method and verify.

var cluster = dba.getCluster()
cluster.status()

SELECT * FROM performance_schema.replication_group_members;

Start the service (two possible ways):

# Method 1
systemctl start

# Method 2
mysqld_safe --defaults-file=/*.cnf --user=mysql &

4.5 Switch Primary Before Upgrading Old Primary Node

When versions are the same, you can use the following command to set a new primary (not applicable when versions differ).

# shell using 8.0 (5.7 not supported)
cluster.setPrimaryInstance('[email protected]:6681')
# Simplified version
cluster.setPrimaryInstance('mgr01:3306')

# Manual primary selection for >8.0.13 (recommended)
SELECT group_replication_set_as_primary('select @@server_uuid');

If you cannot switch primary, stop group replication on the old primary so it automatically fails over.

# Low versions cannot SELECT to higher version; exit group replication to trigger automatic failover.
stop group_replication;
read_only=1; super_read_only=1;

4.7 Upgrade Group Communication Protocol (> MySQL 8.0.16)

The function group_replication_get_communication_protocol returns the minimum MySQL version that supports the current protocol.

SELECT group_replication_get_communication_protocol();
SELECT group_replication_set_communication_protocol("8.0.33");

-- Although the SET succeeds, the query still shows the lowest supported version. After upgrading, the protocol should be updated accordingly.
SELECT group_replication_get_communication_protocol();
+------------------------------------------------+
| group_replication_get_communication_protocol() |
+------------------------------------------------+
| 8.0.27                                         |
+------------------------------------------------+

4.8 Verification

After a successful upgrade:

select version();
+-----------+
| version() |
+-----------+
| 8.0.33    |
+-----------+

If this is a replica, restart replication:

stop group_replication;

5 Rollback

If the startup fails, restart with the original software version.

Clean redo log files: rm -f ib_logfile{0,1,2,3}

Remove symlink and start the old version.

unlink mysql
mv mysql_Basedir mysql_Basedir_bak
ln -s mysql-8.0.xx-old-version-linux-glibc2.12-x86_64 mysql_Basedir
# Start service

6 Node Switching

Custom node switching (normally automatic).

Node weight: group_replication_member_weight – larger value gets higher priority.

server_uuid – smaller value is more likely to be chosen as primary.

7 Common Issues During Upgrade

When starting the database, check the error log for deprecated warnings and remove or replace them.

2023-09-04T08:54:54.092942-00:00 0 [Warning] [MY-011068] [Server] The syntax '--admin-ssl=off' is deprecated and will be removed in a future release. Please use --admin-tls-version='' instead.
2023-09-04T08:54:54.092975-00:00 0 [Warning] [MY-011068] [Server] The syntax 'skip_slave_start' is deprecated and will be removed in a future release. Please use skip_replica_start instead.

Correct upgrade messages look like:

2023-09-04T08:55:10.136353-00:00 7 [System] [MY-013381] [Server] Server upgrade from '80027' to '80033' started.
2023-09-04T08:55:12.621536-00:00 7 [System] [MY-013381] [Server] Server upgrade from '80027' to '80033' completed.

Low‑version nodes cannot be promoted to higher‑version primary:

2023-09-07T07:41:09.211541-00:00 59 [ERROR] [MY-013223] [Repl] The function 'group_replication_set_as_primary' failed. ... The appointed primary member has a version that is greater than the one of some of the members in the group.

The reason is that a new member checks the group's announced communication protocol version; if the member does not support it, it is expelled from the group. For example, a MySQL 5.7.24 instance cannot join a group using protocol version 8.0.16.

Non‑recommended method: use group_replication_set_communication_protocol("5.7.25") to allow older members to join.

8 Summary

This method is an in‑place upgrade; the core step is replacing the old software package (basedir) with the new one, suitable for minor version upgrades.

Other upgrade methods include logical backup (mysqldump or MyDumper) followed by import into the new version.

For large‑scale major upgrades, you can set up a low‑version master replicating to a high‑version slave and then switch roles.

After thorough testing, choose the method you are most comfortable with.

References

MySQL 8.0 Release Notes: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/

Upgrade Prerequisites: https://dev.mysql.com/doc/refman/8.0/en/upgrade-prerequisites.html

MySQLReplicationUpgradeDatabase AdministrationMGRIn-Place Upgrade
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.