mysql主从报错Got fatal error 1236原因和解决方法

主从报错信息

Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position'
![](https://img2020.cnblogs.com/blog/2069550/202109/2069550-20210907173819764-444745734.png)

120611 20:39:38 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236)
120611 20:39:38 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position', Error_code: 1236
120611 20:39:38 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000143', position 664526789

主从报错原因

由于异常断电导致启动主库服务后,从库读取主库binlog位置信息错误,主机异常掉电导致binlog 未及时同步到磁盘。从库读取了主库binlog file中的不存在的binlog position ,一般比binlogfile 的end position 的值还要大。

解决方法

在从库重新指向到主库下一个可用的binlog file 并且从binlog file初始化的位置开始

stop slave;
change master to master_log_file='mysql-bin.000144', master_log_pos=4;
start slave;

参考文档

http://blog.itpub.net/22664653/viewspace-1714269/

原文地址:https://www.cnblogs.com/whiteY/p/14949973.html