场景:有同事需要把从库中的数据,同步一份到新环境,但发现在主库上执行count语句,和从库上执行count语句得出的结果不同。
解决思路:
在从库上执行 show slave status \G ,查看返回结果:
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.118
Master_User: bak
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: MySQL-bin.000728
Read_Master_Log_Pos: 586670704
Relay_Log_File: mysqld-relay-bin.002178
Relay_Log_Pos: 457911949
Relay_Master_Log_File: mysql-bin.000709
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: mydb
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1062
Last_Error: Error 'Duplicate entry