mysql主從不同步、資料不一致解決辦法
提示報錯:
Could not execute Write_rows event on table injured_dataplatform.injurysite; Duplicate entry '6864' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysql-bin.000412, end_log_pos 928740435
解決方法:
從庫執行
#停止slave服務
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
#跳過一步錯誤,後面的數字可變,如果還不行可執行多次
mysql> set global sql_slave_skip_counter =1;
Query OK, 0 rows affected (0.00 sec)
#開始slave服務
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
#檢視slave狀態
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.20.195
Master_User: test
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 251
Relay_Log_File: mysqld-relay-bin.000006
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000004
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table: mysql.%,information_schema.%,performance_schema.%
Last_Errno: 0
Last_Error:
Skip_Counter: 1
Exec_Master_Log_Pos: 251
Relay_Log_Space: 552
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)