centos7.5 删除表空间文件失败

问题:

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

原因:

在MySQL在InnoDB中设置了foreign key关联,造成无法更新或删除数据。可以通过设置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)

相关文章:

  • 2021-10-16
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2021-11-10
  • 2021-10-01
  • 2021-06-28
相关资源
相似解决方案