Mysql Error

I was running an import script today taken from a mysqldump from another user, when I saw an error that looked like this:

ERROR 1005 (HY000) at line 123: Cant create table  (errno: 150)

This is caused by a mysqldump or export process exporting tables in alphabetical order and not in the order in which they rely on one another. My tables had foreign keys which fail on import if the other table doesn’t exist when you create the table with the key. In this case I was only importing six or eight tables so I simply opened the script in a text editor and re-ordered the import blocks. On a bigger scale a more technical solution might be required!

2 thoughts on “Mysql Error

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.