Migrating MySQL database structure with foreign keys fails I am trying to set up a new testing server with a somewhat complex database structure by dumping the old database and importing it. But even though I use SET FOREIGN_KEY_CHECKS=0;, the import fails with Can't create table 'DatabaseX.TableY' (errno: 150).

The referenced table probably doesn't exist yet, so I understand why it complains. But I just can't figure out how to reorder the dumpfile in such a way that the import works, or how to make MySQL ignore missing tables etc during import.
Doh, I noticed that there was some remains from an earlier, botched migration. Dropped all databases, and then import worked.