I need to load a database backup from some months ago.There are 29 tables backed up as individual.sql files. Is the order I load them important? For instance the ClientSupplementary table has a FK into the Client Table so that if the Client is deleted the Supplementary data is as well. So does the Client have to be loaded before their Supplementary information?
Usually yes, when foreign keys are involved, you have to create them in the right order.
When you are sure, however, that your data is consistent, you can do it like this:
mysql> USE your_schema; mysql> SET FOREIGN_KEY_CHECKS=0; mysql> SOURCE /path/to/your/dump/file1.sql mysql> SOURCE /path/to/your/dump/file2.sql mysql> # ... mysql> SET FOREIGN_KEY_CHECKS=1;
Or on the command line:
shell> mysql -uuser your_schema -e "SET GLOBAL FOREIGN_KEY_CHECKS=0;" shell> cat file1.sql file2.sql | mysql -uuser your_schema shell> mysql -uuser your_schema -e "SET GLOBAL FOREIGN_KEY_CHECKS=1;"