MySQL同步报错:Last_IO_Error: Got fatal error 1236 from master

配置MySQL从库,启动slave线程后”Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Could not find first log file name in binary log index file”的错误❌

  • step 1

先到slave中停止同步线程

1
mysql>  stop slave for channel "db136";  # mysql5.7多源复制的语法
  • step 2

回到master中,关闭当前的二进制日志文件并创建一个新文件,新的二进制日志文件的名字在当前的二进制文件的编号上加1

1
2
3
4
5
6
7
8
mysql> flush logs;
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000038 | 154 | | mysql | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
  • step 3

再从slave执行change master

1
2
3
mysql> change master to master_host="192.168.1.136", master_port=3306, master_user="repl",master_password="12345678",master_log_file="mysql-bin.000038",master_log_pos=154 for channel "db136";
mysql> start slave for channel "db136";
mysql> show slave status for channel "db136";