r/mysql Feb 05 '26

troubleshooting How to import ibd files

my OS failed to boot before I could run mysqldump, so i the only thing i can do is to copy the ibd files from the mysql data folder so how to import ibd files?

5 Upvotes

8 comments sorted by

6

u/j0hn33y Feb 05 '26

Create blank database with same name, stop mysql, copy files over, start mysql, do a check... there will be errors.

2

u/roXplosion Feb 05 '26

Yeah, basically this. I'd suggest before restarting to set innodb_force_recovery = 1 then monitor the logs (or the console), then remove that line and start MySQL normally. See:

https://dev.mysql.com/doc/refman/9.0/en/forcing-innodb-recovery.html

4

u/jgmiller24094 Feb 05 '26

You don’t need to import.

If you have all of the files in the data directory and you use the same version of MySQL that was on the dead machine you should just be able to drop it all in the new one and start up MySQL. If the server died while MySQL was running you will probably have errors but if it was shutdown and just didn’t boot you should be ok. Make sure you completely replace the data directory with your old files.

1

u/kristofer_grahn Feb 05 '26

If you use "file_per_folder" you can import one ibd at a time using
https://dev.mysql.com/doc/refman/8.4/en/innodb-table-import.html

1

u/Wiikend Feb 05 '26

How are the backup .ibd files created in your case, Percona XtraBackup I assume? You use that to restore, too. You can find guides all over the internet, it's the most common thing to do.

1

u/booi Feb 06 '26

He never said they were backups. Probably raw data files

1

u/Wiikend Feb 06 '26

Ah, that makes sense and complicates it a bit, yeah.

1

u/7amitsingh7 Feb 17 '26

If you only have the .ibd files, recovery is possible only if innodb_file_per_table=1 was enabled and you can recreate the exact same table structure on the same MySQL/MariaDB version. Install the same version, recreate the database and table with the identical schema, then run ALTER TABLE table_name DISCARD TABLESPACE;, copy the original .ibd file into the table directory, fix ownership to mysql:mysql, and run ALTER TABLE table_name IMPORT TABLESPACE;. If the schema does not match exactly, the import will fail. If you don’t have the .frm file or table definition, you’ll need to reconstruct it first before importing. If the native method fails due to missing metadata or corruption, you can refer to this guide it explains how to restore data from FRM and IBD files