If your MySQL database is corrupted or accidentally deleted, but the .frm and .ibd files remain, recovery is still possible. This article shows how to restore a MySQL database from .frm and .ibd files, including preparing the environment, importing tablespaces, fixing InnoDB issues, and verifying recovered data.
In MySQL, each table is stored on disk as one or more physical files that work together to define the table and store its data. Among these files, .frm and .ibd play a critical role in how MySQL manages table structures and data storage.
A .frm file stores the table structure, such as: Table name; Column names; Data types (INT, VARCHAR, etc.); Primary keys and indexes
👉Think of it as the blueprint of a table.Without the .frm file, MySQL doesn’t know how the table is defined.
An .ibd file is used by the InnoDB storage engine and contains the actual data, including: Table records (rows) and Index data.
👉Think of it as the warehouse where the table’s data is stored. If the .ibd file is missing, the table structure may exist, but the data is gone.
| File | Purpose | Required |
| .frm | Table structure definition | Yes |
| .ibd | Table data and indexes | Yes (InnoDB tables) |
Before jumping into the recovery steps, it’s important to understand when and why you may need to restore MySQL data from .frm and .ibd files. This situation usually occurs when logical backups are unavailable, but the original table files still exist.
In these cases, restoring MySQL tables from .frm and .ibd files may be the only practical way to recover your data.
The following method applies to InnoDB tables and requires that the .frm and .ibd files come from the same original table.
First, install the same MySQL version that was used on the original server whenever possible. Using an identical or very close version helps avoid tablespace and compatibility issues during recovery. Before performing any file operations, completely stop the MySQL service to prevent file locking or further corruption.
Next, check the MySQL configuration file (my.cnf or my.ini) and confirm that the innodb_file_per_table option is enabled. This setting ensures that each InnoDB table uses its own .ibd file, which is required for importing tablespaces. If you make changes to the configuration, restart MySQL to apply them.
After MySQL is running normally, recreate the database where the table will be restored. Once the database exists, create an empty table using the exact same structure as the original one. The table definition must match precisely, including column order, data types, index definitions, storage engine, and character set.
Even small differences in the table structure can cause the tablespace import to fail. After creating the table, verify that it contains no data to ensure it is ready for recovery.
Stop the MySQL service again after the empty table is created. Navigate to the database directory inside the MySQL data folder and locate the .ibd file that was automatically generated for the new table.
Delete this newly created .ibd file, as it will be replaced by the original one. Do not remove the .frm file, since it defines the table structure needed for the import process.
Copy the original .ibd file into the same table directory where the deleted file was located. Make sure the file name matches the table name exactly. Then adjust file ownership and permissions so they match other MySQL data files, ensuring MySQL can access the file without permission errors.
Start the MySQL service and connect to the database. Run the following SQL command to import the tablespace:
ALTER TABLE table_name IMPORT TABLESPACE;
MySQL will attach the original .ibd file to the table and attempt to restore the data. If the command completes successfully, the table data should become accessible immediately.
Finally, run basic SELECT queries to confirm that the data has been restored correctly. Check the number of rows and test key indexes to ensure the table behaves as expected. Once verification is complete, it is strongly recommended to back up the recovered data as soon as possible.
.FRM files define the table structure, including columns, indexes, and table properties, while .IBD files store the actual table data and indexes. If either file is missing or corrupted, MySQL cannot access the table. Understanding these files is crucial for any recovery attempt, and tools like MyRecover can simplify restoring both .FRM and .IBD files safely.
Yes, it is possible to restore the table by carefully importing the original .IBD file into a new table with the same structure. However, this process can be tricky, and any mismatch in table definitions or file permissions can cause errors. For users looking for a safer solution, professional tools like MyRecover can help automate the recovery of MySQL files from damaged or deleted directories.
Common causes include accidental table or database deletion, server crashes, disk failures, improper migrations, or MySQL misconfigurations. Even if the database seems gone, the .FRM and .IBD files may still exist and serve as a source for recovery.
Manually copying .IBD and .FRM files is risky because any misstep can overwrite data. Using a reliable recovery tool like MyRecover ensures that deleted, lost, or corrupted MySQL files can be safely restored while preserving table integrity. MyRecover supports scanning the disk and recovering InnoDB tables, even if the database is no longer visible in MySQL.
Yes, regular backups are essential. Use logical backups (mysqldump) or physical backups (copying the entire MySQL data directory safely). Additionally, enabling innodb_file_per_table ensures that each InnoDB table has its own .IBD file, simplifying recovery.
Recovering MySQL data from .FRM and .IBD files can seem challenging, but understanding the role of these files and following a careful restoration process makes it achievable. By preparing a clean environment, recreating table structures accurately, and importing the original tablespaces, you can restore lost or corrupted InnoDB tables safely.
When it comes to recovering lost, or deleted files without any backup, MyRecover comes in as a professional data recovery solution. It is capable of restoring over 1,000 different file types across more than 500 data loss scenarios.