Setting Up MySQL 8.0 to MySQL 5.7 Replication
This guide explains how to configure replication from a MySQL 8.0 master to a MySQL 5.7 slave, covering supported version combinations, character‑set adjustments, authentication plugin changes, user creation, CHANGE MASTER commands, status verification, quick testing, and common pitfalls when using newer MySQL features.
This article demonstrates how to set up replication from MySQL 8.0 (master) to MySQL 5.7 (slave), which can be useful in upgrade or master‑master migration scenarios.
Supported version matrix :
master 5.7 → slave 8.0 : supported
master 8.0 → slave 5.7 : not supported
Because MySQL replication only works between consecutive major versions and from lower to higher, the only viable direction for a mixed‑version topology is 5.7 master to 8.0 slave; however, the article shows how to make 8.0 → 5.7 work by adjusting settings.
Character set and collation changes – MySQL 8 defaults to utf8mb4 and utf8mb4_0900_ai_ci . To avoid “character set not compiled” errors on the slave, modify the master’s my.cnf :
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
collation-server=utf8_unicode_ciRestart MySQL 8.0 after editing the configuration.
Authentication plugin – MySQL 8 uses caching_sha2_password by default, which MySQL 5.7 does not understand. Create the replication user with the legacy mysql_native_password plugin:
CREATE USER 'replica_user'@'%' IDENTIFIED WITH mysql_native_password BY 'repli$cat';
GRANT REPLICATION SLAVE ON *.* TO 'replica_user'@'%';Change master command – after the user is created, run on the slave:
CHANGE MASTER TO MASTER_HOST='127.0.0.1',
MASTER_USER='replica_user',
MASTER_PASSWORD='repli$cat',
MASTER_PORT=19025,
MASTER_LOG_FILE='mysql-bin.000007',
MASTER_LOG_POS=155;
START SLAVE;For GTID‑enabled setups you can use MASTER_AUTO_POSITION = 1 instead of specifying log file and position.
Verification – check the replication status on the slave:
SHOW SLAVE STATUS\GKey fields such as Slave_IO_Running and Slave_SQL_Running should be Yes , and Last_Errno should be 0.
Quick test – create a test database on the master and confirm it appears on the slave:
CREATE DATABASE vinnie;
SHOW DATABASES LIKE 'vinnie';Important notes – using MySQL 8 features like RULE , invisible indexes, or caching_sha2_password will cause replication to stop with errors such as Last_SQL_Errno: 1396 . Stick to the legacy authentication plugin for cross‑version replication.
Conclusion – Replication from MySQL 8.0 to MySQL 5.7 is possible with the adjustments described, but it is not recommended for heterogeneous topologies because of compatibility risks.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.