逐梦论坛's Archiver

shillan 发表于 2016-4-27 01:50

MySQL主从同步主键重复Duplicate entry手动解决

[b]现象:[/b]从机状态:
[quote]Slave_IO_Running: Yes
Slave_SQL_Running: No[/quote]
报类似如下错误:
[quote]Last_SQL_Error: Error 'Duplicate entry '144654' for key 'PRIMARY'' on query. Default database: 'x4j'. Query: 'INSERT INTO mac_user_visit (uv_uid,uv_ip,uv_ly,uv_time) VALUES('80','-1347584867','','1461546069')'

Last_SQL_Error: Error 'Duplicate entry '27575' for key 'PRIMARY'' on query. Default database: 'x4j'. Query: 'INSERT INTO mac_user (u_name,u_qid,u_password,u_qq,u_email,u_regtime,u_status,u_points,u_group,u_phone,u_question,u_answer) VALUES('丶4','67F89C8D94396EEAD8D3A6807A5D1147','a41d8cd98f00b204c9800998ecf8427b','','','1461561325','1','1','1','','','')'[/quote]

[b]解决:[/b][code]mysql>set global sql_slave_skip_counter=1;
mysql>start slave;[/code]上面的语句是告诉从库slave_sql线程让它忽略掉这个错误继续执行。

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.