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://www.cnblogs.com/datalife/p/8915711.html