MySQL “Error 1005” when adding tables

ε祈祈猫儿з 提交于 2019-11-30 09:06:41

问题


I've recently been working with a MySQL database, and using MySQL workbench to design the Database.

When I use the export to SQL function, so I can actually get the layout in to the Database, I get:

"Error 1005: Cannot create table"

This appears to be related to Foreign Keys in the create table statement.

Does anybody have a work around for this that doesn't involve taking the constraints out and putting them back in later? That's a less than ideal solution given the size of the database.


回答1:


When you get this (and other errors out of the InnoDB engine) issue:

SHOW ENGINE INNODB STATUS;

It will give a more detailed reason why the operation couldn't be completed. Make sure to run that from something that'll allow you to scroll or copy the data, as the response is quite long.




回答2:


I ran into this situation recently when I attempted (in InnoDB tables) to make a foreign key reference to a column that had a different data type.

MySQL 5.1 Documentation



来源:https://stackoverflow.com/questions/34579/mysql-error-1005-when-adding-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!