当前位置:
首页
文章
数据库
详情

Mysql主从库不同步1236错误:could not find first log file name in binary....

文章来自:Mysql主从库不同步1236错误:could not find first log file name in binary....

问题分析:

  1. 主库执行命令,确认日志文件和位置;

mysql > show master status;

+------------------+----------+--------------+------------------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB             | Executed_Gtid_Set |
+------------------+----------+--------------+------------------------------+-------------------+
| mysql-bin.001724 | 703460812|              | information_schema,sys,mysql |                   |
+------------------+----------+--------------+------------------------------+-------------------+
  1. 从库执行命令,确认日志文件和位置;

mysql > show master status;

+------------------+----------+--------------+------------------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB             | Executed_Gtid_Set |
+------------------+----------+--------------+------------------------------+-------------------+
| mysql-bin.001240 | 333460812|      ***     | information_schema,sys,mysql |                   |
+------------------+----------+--------------+------------------------------+-------------------+

解决办法:

  1. 首先停止从库同步;

mysql > stop slave ;

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

mysql > flush logs;

  1. 查看主库状态,主要查看日志文件和位置:

mysql > show master status;

  1. 回到从库中,执行命令,使日志文件和位置对应主库:

mysql > CHANGE MASTER TO MASTER_LOG_FILE='log-bin.000005',MASTER_LOG_POS=107;

  1. 最后,启动从库:

mysql > start slave ;

mysql > show slave status;
设置忽略错误命令:set global sql_slave_skip_counter =1;

状态如下,基本上是正常了,可以主库修改,测试一下从库是否同步。

Slave_IO_State: Waiting for master to send event
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

如出现异常:ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository

mysql > reset slave;
mysql > start slave;

免责申明:本站发布的内容(图片、视频和文字)以转载和分享为主,文章观点不代表本站立场,如涉及侵权请联系站长邮箱:xbc-online@qq.com进行反馈,一经查实,将立刻删除涉嫌侵权内容。