Upgrade MySQL to 8.0? Yes, but Avoid Disaster!

October 5, 2024
Author
Przemysław Malkowski
Share this Post:

Upgrading to MySQL version 8.0 is a hot topic since version 5.7 is approaching official end of life very soon. MySQL 5.7 EOL is set for the end of October 2023.

If you feel unprepared for the upgrade, consider post-EOL support from Percona. But it would be the worst if you proceeded with the upgrade in haste.

  • Long database service downtime
  • Some queries become slow
  • Applications stop working due to incompatibilities
  • Data loss

This is what can happen if MySQL’s major upgrade to 8.0 turns out not as you hoped for. Yes, it can be that serious, so do consider the major upgrade as an important project, not just a routine maintenance task.

From my experience as a Support Engineer, I think the most frequent problem is query performance after an upgrade. This single problem can potentially render your site down if the execution plan changes for worse for a frequent enough query.

Although there are tools and methods to prepare and test the upgrade before going live, often not all problems can be anticipated. For example, while it is possible to test read workload, it is pretty difficult to test things write-related. Often QA/staging environments do not resemble production 100%, especially regarding scale, and surprises are very possible.

Therefore, you may find yourself in a situation where the only quick rescue after an unsuccessful MySQL upgrade is to downgrade back to the previous version.

If it becomes clear that you have to revert the upgrade immediately after it’s done, the solution should be simple: reinstall the 5.7 version packages and restore the full backup taken right before the upgrade. In fact, it’s the only officially supported downgrade method.

It becomes much more difficult if the revert decision has to be taken later when new data has already been added. As MySQL does not support downgrades from 8.0, you are left with more challenging and not officially supported alternatives if you can’t just discard all the new writes that happened under version 8.0.

Ensure your databases are performing their best — today and tomorrow — with proactive database optimization and query tuning. Book a database assessment

Possible downgrade options

  • Logical data dump from 8.0 and restore to 5.7
  • Utilize a 5.7 replica
  • Restore the last pre-upgrade backup and apply missing data from binlogs created on 8.0

A logical dump/restore downgrade

While logical downgrade was officially supported from MySQL 5.7 to 5.6:

https://dev.mysql.com/doc/refman/5.7/en/downgrade-paths.html

It is no longer the case for 8.0 to 5.7:

https://dev.mysql.com/doc/refman/8.0/en/downgrading.html

The entire “Downgrading MySQL” section of the documentation was basically reduced to a statement that it is not supported; therefore, you can try it at your own risk.

Now, the first issue with the logical dump/restore approach, as somewhat expected, is with system tables. You cannot dump the MySQL system database from MySQL 8.0 and load it back to MySQL 5.7. It will break it completely.

So, if you follow a similar procedure as suggested for the 5.7→5.6 downgrade:

https://dev.mysql.com/doc/refman/5.7/en/downgrade-binary-package.html#downgrade-procedure-logical

You will see import errors like these:

The target 5.7 instance then becomes broken and unable to operate because crucial tables are missing. Even the usual upgrade tool won’t fix it:

Therefore, you must dump user tables only, while getting the system tables from the last backup before the upgrade. Any changes in system tables made since the 8.0 upgrade may be a problem, as many basic commands have changed.

For example, you can’t simply dump and restore user definitions:

That means if you want to be prepared for the downgrade path, you need to keep track of every new system property change, like users, passwords, events, stored procedures, etc., and save notes accordingly, with syntax working on 5.7.

If you find that a problem, you may vote for https://jira.percona.com/browse/PT-1698.

Worth mentioning is that the logical dump may be done using a much faster and more robust tool, like MySQL Shell or mydumper. For example, util.dumpInstance() from MySQL Shell, by default, does not back up the system tables for a full backup. Also, util.loadDump() allows you to exclude additional tables if needed. It will warn you about the unsupported action first:

Forcing is possible, though:

Using a 5.7 replica as a backup downgrade path

Having replicas seems like a great opportunity to leave one on version 5.7 for some time after the upgrade to MySQL 8.0. However, again, this is not officially supported:

https://dev.mysql.com/doc/refman/8.0/en/replication-compatibility.html

And although replication from an 8.0 source to a 5.7 replica can work with some effort:

https://www.percona.com/blog/replicating-mysql-8-0-mysql-5-7/

There is one major problem with it: even if you avoid new features, MySQL 8.0 has more charset collations than 5.7, and one of them is the default.

Versus 5.7:

While using utf8 as the default character set for the [client] section in the configuration file works for regular MySQL clients, it won’t help for other applications using MySQL 8.0 drivers or C libraries:

https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html

A simple sysbench against the 8.0 source will break the 5.7 replica with something like:

The binary log contains:

Unfortunately, I found no way to force applications to use utf8 or a 5.7-compatible collation like utf8mb4_general_ci other than changing it inside the application itself.

That means replication may work only if your apps use MySQL 5.7 connectors or if you control the connection settings.

So, if you are lucky enough to deal with the compatibility issue, you may want to upgrade one replica first, then keep another 5.7 replica below it as a downgrade path.

While these screenshots were made from Orchestrator, which makes it easy to change replication topologies, I still had to move the 5.7 replica under the 8.0 source manually, because this is unsupported:

As long as it works for you, this topology allows you to run applications on MySQL 8.0 while still keeping a 5.7 recovery replica. In case of emergency downgrade, downtime can be minimal.

Downgrade by restoring the 5.7 backup and applying new binlogs (PITR)

This combines a straightforward backup restore step with another unsupported action: applying binlogs produced by 8.0 to 5.7. The same incompatibility issues as replication apply.

To work around this, you can convert charset/collation values on the fly:

On 5.7, use compatible values:

Then rewrite the binlog stream before applying:

This worked for a simple sysbench OLTP workload, but there is no guarantee it will work for yours. Charset is only one of several incompatibility issues.

Upgrade advice

To summarize, I highly recommend considering the following points for a MySQL 8.0 upgrade:

Useful reading:

  • Percona Utilities That Make Major MySQL Version Upgrades Easier
  • Upgrading to MySQL 8: Tools That Can Help
  • MySQL 8 Minor Version Upgrades Are ONE-WAY Only
  • Upgrading to MySQL 8: Embrace the Challenge

And do not hesitate to contact Percona Experts for help preparing and performing the upgrade.

MySQL Performance Tuning is an essential guide covering the critical aspects of MySQL performance optimization.

Download and unlock the full potential of your MySQL database today.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved