mysql主从同步Last_SQL_Errno: 1061

1.mysql从库同步报错

Last_Errno: 1061
Last_Error: Error 'Duplicate key name 'serCheckUser_log_time_index'' on query. Default database: 'bbh_9'. Query: 'CREATE INDEX serCheckUser_log_time_index on serCheckUser (log_time)'

#
异常描述:误把从节点当成主节点插入一条数据,同一条数据在主、从节点插入都进行了一次插入操作,导致主键冲突,slave下的SQL线程异常。

2.登录数据库,查看报错对应索引

mysql> use bbh_9;
mysql> show index from serCheckUser;

3.删除索引

mysql> ALTER TABLE `serCheckUser` DROP INDEX `serCheckUser_user_index`;
mysql> ALTER TABLE `serCheckUser` DROP INDEX `serCheckUser_log_time_index`;

4.重启主从同步

mysql> stop slave;
mysql> start slave; 
mysql> show slave status\G;

posted @ 2022-01-24 17:10  chenjianwen  阅读(814)  评论(0编辑  收藏  举报