Slave can not handle replication events with the checksum that master is configured to log;

一. 问题背景

搭建mysql主从复制:

  • 主机:在windows上,mysql版本5.7
  • 从机:在CentOS7上,mysql版本5.5

报错:Slave can not handle replication events with the checksum that master is configured to log;

解释: 一般出现在主机版本比从机版本高。由于5.7使用了crc32做binlog的checksum;
当一个event被写入binary log(二进制日志)的时候,checksum也同时写入binary log,然后在event通过网络传输到从服务器(slave)之后,再在从服务器中对其进行验证并写入从服务器的relay log.

二. 解决方案

  1. 关闭主机上的MySQL服务
  2. 打开主机上MySQL的my.ini文件,在[mysqld]下输入binlog_checksum =none,如下:
    在这里插入图片描述
  3. 保存my.ini文件,启动主机上的mysql服务。
  4. 在从机上按ctrl+c关闭当前进程,然后输入service mysql restart;重启MySQL服务
  5. 重启完后,在从机上输入mysql -uroot -p123456(p后面为你的数据库密码,u后面为你的数据库用户名)
  6. 进入mysql后,先stop slave;
  7. 然后到主机那里flush logs;,再show master status;,查到如下:
    在这里插入图片描述
  8. 在从机里面change master to master_log_file='上面图中第一个红色圈的值',master_log_pos=第二个红色圈的值;
  9. 在从机里面slave start;
    10.在从机里面show slave status\G;,就可以看到如下:

在这里插入图片描述

发布了352 篇原创文章 · 获赞 20 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_40634846/article/details/105267941