One of the reasons why MySQL fails to create foreign keys

When I created a foreign key, I reported the following error: 1215 Cannot add foreign key constraint

I checked on the Internet, most of which are caused by inconsistent types on both sides, but my field types are consistent. Inadvertently, I found that the engine of the parent table is different from the engine of the child table. I tried to modify the engine of the parent table to be consistent with the child table, and then rebuilt the external table, which was successful. Students who have encountered such errors can try it out. If you find similar errors caused by other reasons, please do not hesitate to let me know.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326266525&siteId=291194637