返回列表 发帖

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

现象:从机状态:
Slave_IO_Running: Yes
Slave_SQL_Running: No

报类似如下错误:
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','','','')'


解决:
  1. mysql>set global sql_slave_skip_counter=1;
  2. mysql>start slave;
复制代码
上面的语句是告诉从库slave_sql线程让它忽略掉这个错误继续执行。
欢迎光临:逐梦论坛

返回列表

Powered by Discuz! 7.2   论坛QQ群:逐梦论坛群

© 2001-2021 Comsenz Inc. 鲁公网安备 37120302000001号