MySQL Error 1215: Cannot add foreign key constraint

前端 未结 30 3386
予麋鹿
予麋鹿 2020-11-22 01:37

I am trying to forward engineer my new schema onto my db server, but I can\'t figure out why I am getting this error. I\'ve tried to search for the answer here, but everyth

30条回答
  •  猫巷女王i
    2020-11-22 02:25

    So I tried all the fixes above and no luck. I may be missing the error in my tables -just could not find the cause and I kept getting error 1215. So I used this fix.

    In my local environment in phpMyAdmin, I exported data from the table in question. I selected format CSV. While still in phpMyAdmin with the table selected, I selected "More->Options". Here I scrolled down to "Copy table to (database.table). Select "Structure only". Rename the table something, maybe just add the word "copy" next to the current table name. Click "Go" This will create a new table. Export the new table and import it to the new or other server. I am also using phpMyAdmin here also. Once imported change the name of the table back to its original name. Select the new table, select import. For format select CSV. Uncheck "enable foreign key checks". Select "Go". So far all is working good.

    I posted my fix on my blog.

提交回复
热议问题