There are times when what you have is a partially running
database and a bunch of backup innodb tablespace files (the .ibd
files). If you're using innodb_file_per_table
, then
you have a separate .ibd file for each InnoDB table.
Now, you have your running database with a bunch of tables, and
you want to replace some of them with the backup .ibd files.
According to the MySQL docs, you'd do this:
-
ALTER TABLE foo DISCARD TABLESPACE;
(this deletes the current .ibd file) - copy the old .ibd file into your database directory
-
ALTER TABLE foo IMPORT TABLESPACE;
Assuming your .ibd file was from the same database and you did not drop the table and recreate it sometime between when you made the backup .ibd and now, this should work. Except... if …
[Read more]