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

This may be because MySQL has set foreign Key association in InnoDB, which makes it impossible to update or delete data. You can avoid this situation by setting the FOREIGN_KEY_CHECKS variable.
SET FOREIGN_KEY_CHECKS = 0;
SET
SET FOREIGN_KEY_CHECKS = 1;

SET FOREIGN_KEY_CHECKS = 0;
SET
SET FOREIGN_KEY_CHECKS = 1;
ERROR 1452 (23000): Cannot add or update a Child row: a foreign key constraint fails…… (foreign key restrictions cannot be inserted)
can also use (SET FOREIGN_KEY_CHECKS = 0; ) insert

Read More: