mysql主从问题 Error ‘Duplicate entry ‘10587590’ for key ‘PRIMARY” on query. Default database: ‘test’. Query: ‘INSERT INTO `user_invite_relation` (`user_info_id`, `parent_id`, `level`) VALUES (‘10592996’, ‘10592991’, ’82’)’

  sre

5faba8b33fbd27989.jpg_fo742.jpg
主库插入重复主键导致从库不工作了,错误消息如下

Error 'Duplicate entry '10587590' for key 'PRIMARY'' on query. Default database: 'test'. Query: 'INSERT INTO `user_invite_relation` (`user_info_id`, `parent_id`, `level`) VALUES ('10592996', '10592991', '82')'

临时解决:

 mysql> slave stop;
 mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
 mysql> slave start;

永久解决:

修改从库mysql配置文件 /etc/my.cnf
在[mysqld]下加一行 slave_skip_errors = 1062
重启从库

LEAVE A COMMENT

Captcha Code