Wednesday, July 19, 2017

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


>PROBLEM

Running the script like this:
  \. myScript.sql
fails and returns the message:
  ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

Nevertheless, if running the command straight on the console, it may work.



>SOLUTION

This issue was solved checking the file's encoding versus the database encoding and matching them.
So, the database was UTF-8, and the script was using the same encoding.



>ENV
Windows
MySQL 5.5

No comments:

Post a Comment