搭建 MySQL 主從同步時,從庫 IO 線程啟動失敗,報錯:
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log:
'Slave can not handle replication events with the checksum that master is configured to log;
the first event 'binlog.000005' at 805...'
Slave_IO_Running: No,Slave_SQL_Running: Yes
SET GLOBAL binlog_checksum = 'NONE';
SHOW VARIABLES LIKE '%checksum%';
編輯 my.cnf(或 my.ini),在 [mysqld] 區塊添加:
binlog_checksum = NONE
-- 主庫查看最新 Binlog 位點
SHOW MASTER STATUS\G;
-- 從庫停止同步、重新指向、啟動
STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='binlog.000005', MASTER_LOG_POS=805;
START SLAVE;
SHOW SLAVE STATUS\G;
執行 SHOW SLAVE STATUS\G 確認:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Seconds_Behind_Master: 0
Slave_IO_Running、Seconds_Behind_Master、Last_IO_Error,異常即時報警| 值 | 含義 | 適用版本 |
|---|---|---|
| NONE | 不校驗,兼容性最好 | 所有版本 |
| CRC32 | 循環冗餘校驗,檢測數據損壞 | MySQL 5.6+ |
| XXH64 | xxHash 64位,性能更優 | MySQL 8.0.30+ |
生產環境建議:主從版本一致時開啟 CRC32 保障數據完整性;版本混用時統一設為 NONE。