Mysql 主从备份 Duplicate entry for key PRIMARY
2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
严重: Servlet.service() for servlet jsp threw exception com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '8
昨天检查mysql数据库 master-slave同步 是否出问题,果然出乎意料。
进入mysql
SHOW SLAVE STATUS\G;
出现: Slave_SQL_Running: No
原因是:
[ERROR] Slave SQL: Error 'Duplicate entry '349' for key 'PRIMARY'' on query.
[ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START".
重复insert 相同primary key 导致 slave SQL thread终止。而Slave I/O thread 正常运行。
解决办法:
直接使用最初【第一次搭建主从备份时候】mysql主服务器的数据库备份(即the snapshot of the master ),将当前的数据库还原到 最初的状态。进入mysql命令行, 将slave服务终止: stop slave ; 再还原 从数据库。
mysql -uusername -ppassword databasename1 < database1_backup.sql mysql -uusername -ppassword databasename2 < database2_backup.sql
推荐:mysql Duplicate entry ''xxx" for key 'NewIndex1'错误
今天在mysql插入时老是报这样的错误,根据报错信息,NewIndex是有关索引的。于是查看索引: 可见插入的week,year,userId这一组数据放在一起是不能重复的。 而我
然后start slave ; 通过show slave status/G;或者tail -f /var/log/mysqld.log 查看是否出错 .
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Nice !!! 这个方法并没有从根本上解决问题。
参考:
http://dev.mysql.com/doc/refman/5.6/en/reset-slave.html RESET SLAVE 语法 这里不解释 reset slave 具体作用
http://www.lpfrx.com/archives/917/ MySql的备份数据库和MySql还原恢复数据库命令
http://chenxy.blog.51cto.com/729966/304392 MYSQL主从同步故障 (这个修复的方法还没试,如果之前没有备份,可以试试这种方法).
推荐:mysql Duplicate entry for key 解决
遇到一个奇怪的问题,Duplicate entry 1 for key 1 , 看了数据库里面的id并没有超过它的类型int的范围。当时最大的id是20334,在数据库里面直接插入id为20335的
相关阅读排行
- 1DOS命令大全(经典收藏)
- 2使用ThinkPHP框架快速开发网站(多图)
- 3Spring mvc+hibernate+freemarker(开源项目) - java,oracle,mysql,jquery,linux,Struts,Spring,Hibernate,maven webservices,Nosql,hudoop,git,osgi,easymock,nginx,jbpm,jni,jpa等资料下载地址 http://pa
- 4MyBatis学习 之 一、MyBatis简介与配置MyBatis+Spring+MySql
相关内容推荐
- 1微信公众号文章采集,并发布到WordPress
- 2com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '88888888' for key 'PRIMARY'
- 3mysql Duplicate entry for key 解决
- 4mysql Duplicate entry ''xxx" for key 'NewIndex1'错误
- 5Last_SQL_Error: Error 'Duplicate entry '1' for key 'PRIMARY''
- 6ALTER TABLE报错Duplicate entry '' for key 'PRIMARY'