ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

MySQL在删除一张表时出现

可能是MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据。可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况。

SET FOREIGN_KEY_CHECKS = 0;

然后就可以删除表了。

删除完成后设置

SET FOREIGN_KEY_CHECKS = 1;

drop table slow_log cascade;

ERROR 1580 (HY000) at line 1: You cannot ‘DROP‘ a log table if logging is enabled”
解决方法:执行set global slow_query_log=off,然后再次运行mysql

时间: 2024-12-28 10:33:42

ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails的相关文章

MySQL:ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

MySQL在删除一张表时出现 ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails 可能是MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据.可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况. SET FOREIGN_KEY_CHECKS = 0; 然后就可以删除表了. 删除完成后设置 SET FOREIGN_KEY_CHE

mysql ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constrain fails

ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constrain fails. 可能是MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据.可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况. 1.set foreign_key_checks=0; 2.删除要删除的表; 3.set foreign_key_checks=1; 原文地址:https://w

MySQL主从复制中断,报“Error on master: message (format)='Cannot delete or update a parent row: a foreign key constraint fails' error code=1217” 错误

前几天,发现从库挂了,具体报错信息如下: 分析思路 1. 因为我采用的是选择性复制,只针对以下几个库进行复制: card,upay,deal,monitor,collect.所以,不太可能出现对于sas_basic的操作能复制到该从库上. 2. 整个架构是1主2从,且都是选择性复制,上面这个从库是直接复制card,upay,deal,monitor,collect这几个数据库的数据,而另外一个从库则是忽略上述库,如下所示: 怀疑是在上述schema下,执行了DROP TABLE IF EXIST

【转】 #1451 - Cannot delete or update a parent row: a foreign key constraint fails 问题的解决办法

转载地址:http://blog.csdn.net/donglynn/article/details/17056099 错误 SQL 查询: DELETE FROM `zmax_lang` WHERE CONVERT( `zmax_lang`.`lang` USING utf8 ) = 'fr' LIMIT 1 MySQL 返回: #1451 - Cannot delete or update a parent row: a foreign key constraint fails (`myre

关于mysql中[Err] 1451 -Cannot delete or update a parent row: a foreign key constraint fails

今天在弄mysql的时候突然出现一条这个错误信息,当时就蒙逼了,不过仔细观察一番后发现是外键的原因,这是由于在删除表的时候存在外键关联这时候就会出现删除错误,我们可以暂时把mysq数据库的外键约束给关闭掉,具体方法请看如下: [Err] 1451 -Cannot delete or update a parent row: a foreign key constraint fails SET FOREIGN_KEY_CHECKS = 0 //关闭外键约束 进行完操作后别忘记了再把外键约束重新打开

Mysql之1451 - Cannot delete or update a parent row: a foreign key constraint fails...解决办法记录

今天使用delete语句删除一张表中的一条信息时,提示了这么一个错误:1451 - Cannot delete or update a parent row: a foreign key constraint fails...错误代码为1451 在这里参考了一位园友的解决方案mysql删除外链解决办法,如下: 关闭外键约束 SET FOREIGN_KEY_CHECKS=0; 语句执行 DELETE FROM blog_blog WHERE blog_blog.id=91; 删除完成后,重新开启外

MYSQL: Cannot delete or update a parent row: a foreign key constraint fails

这可能是MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据.可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况. SET FOREIGN_KEY_CHECKS = 0; 删除完成后设置 SET FOREIGN_KEY_CHECKS = 1; 其他: 关闭唯一性校验 set unique_checks=0; set unique_checks=1;

Cannot add or update a child row: a foreign key constraint fails

1.错误描述 Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.Nat

insert时报Cannot add or update a child row: a foreign key constraint fails (`yanchangzichan`.`productstatusrecord`, CONSTRAINT `p_cu` FOREIGN KEY (`cid`) REFERENCES `customer` (`cid`))错误

mybatis在insert时报Cannot add or update a child row: a foreign key constraint fails (`yanchangzichan`.`productstatusrecord`, CONSTRAINT `p_cu` FOREIGN KEY (`cid`) REFERENCES `customer` (`cid`))错误,重点在"a foreign key constraint fails",说明主表和附表有外键关联,无法插