2019-06-21
mysql主从同步错误代码1008
# 前一天在主库上建立了daxia数据库,然后立马就删除了,导致从库并没有同步完成,然后再去执行binlog中删除的操作时,找不到daxia数据库,所以导致同步中断。
# 在从库上查看同步状态,如下
MySQL [(none)]> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.1.80
Master_User: tongbu
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000008
Read_Master_Log_Pos: 153538609
Relay_Log_File: mysql2-relay-bin.000013
Relay_Log_Pos: 117201315
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1008
Last_Error: Error 'Can't drop database 'daxia'; database doesn't exist' on query. Default database: 'daxia'. Query: 'DROP DATABASE `daxia`'
# 解决方法:在从库执行,将同步指针移动到下一指令就可以,跳过这个错误。
MySQL [(none)]> stop slave;
MySQL [(none)]> set global sql_slave_skip_counter = 1;
MySQL [(none)]> start slave;