Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Monday, November 28, 2011

MySql Error#1005 – Can’t create table (errno: 121)

I have been MySql Workbench for a long time now and I recommend everyone to use it for their database design needs. Today, I was exporting the mysql database design to .sql file and then importing the sql to mysql server. I got the error
"#1005 - Can't create table 'XXX.xxxx' (errno: 121)". .
I scratched my head, hmmm…. Error #1005 is for foreign key constraint errors, checked the keys, column type and everything looked OK.
After about 10 minutes of fiddling around, I found that I had forgotten to make the foreign key constraint names unique for that particular table. If you are using InnoDB engine, then you need to make sure that all the foreign key constraint names are unique across the entire database and not just the table.
Hopefully, you may find my post helpful and save you some minutes or hours sometimes.

No comments:

Post a Comment