Problem deleting data with FOREIGN KEY constraints in MySQL….

Ah yes. Your working on that system that uses the MySQL FOREIGN KEY constraint on some tables.

You want to truncate a table but get an error message because you have already truncated the data in the related table.

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

Fear not you can disable the constraints in the mysql shell…

mysql> SET foreign_key_checks = 0;
mysql> TRUNCATE some_table;
mysql> SET foreign_key_checks = 1;