I have always used mysqldump to backup my databases..which has always worked.
Recently I started using Innodb tables, in particular, foreign key restraints. The problem is with restoring the database. I create a backup of my database successfully like this:
mysqldump myDatabase > backup.sql -p
Then i try to restore the database:
mysql < backup.sql -p
But I get errors because of the foreign key restraints. It turns out that when mysql made the backup file it didn't check which tables should be created first. The child table is created before the parent table. So in order to fix this I have to edit the backup file manually and move the parent table script above the child table script. Is there a way to make sql recognise the constraints?
Recently I started using Innodb tables, in particular, foreign key restraints. The problem is with restoring the database. I create a backup of my database successfully like this:
mysqldump myDatabase > backup.sql -p
Then i try to restore the database:
mysql < backup.sql -p
But I get errors because of the foreign key restraints. It turns out that when mysql made the backup file it didn't check which tables should be created first. The child table is created before the parent table. So in order to fix this I have to edit the backup file manually and move the parent table script above the child table script. Is there a way to make sql recognise the constraints?