エラー1451(23000):親行を削除または更新できません:外部キー制約が失敗します()



Error 1451 Cannot Delete



centos7.5表スペース・ファイルの削除に失敗しました

問題:



mysql> alter table country discard tablespace ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails ()

理由:

Set in the MySQL InnoDB in association foreign key, resulting in not update or delete data. This situation can be avoided by setting the variable FOREIGN_KEY_CHECKS.

解決:



mysql> SET FOREIGN_KEY_CHECKS = 0 Query OK, 0 rows affected (0.00 sec) mysql> alter table country discard tablespace Query OK, 0 rows affected (0.01 sec) mysql> SET FOREIGN_KEY_CHECKS = 1 Query OK, 0 rows affected (0.00 sec)