MySQL删除行报错的问题

问题描述

在删除表的某行时,报错有

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

解决方法

  1. 关闭外键约束
1
SET foreign_key_checks = 0;
  1. 按情况删除数据,比如
1
delete from server where IP = "192.168.137.1";
  1. 重新开启约束
1
SET foreign_key_checks = 1;


----------- 本文结束 -----------




0%