Restoring MySQL Tables from .ibd, .frm and mysqllogbin files

I finally figured out and resolved my problem through a lot of trial and error. For those who do not have their original ibdata1 file, and only have their .frm and .ibd files, here's how I restored my data.

  1. Download and install the MySQL utilities at -> http://dev.mysql.com/downloads/utilities.
  2. Go into your command/terminal to open the MySQL utility, mysqlfrm, and use it to find the structure of your table that you need to restore. How I did that, was I cd'ed into the file location of mysqlfrm, then entered "mysqlfrm --server=user:pwd@localhost --port=3307 "path_to_.frm_file" > table_name.txt". The .txt file should be saved in the same folder as where your utilities are saved if you didn't specify where you wanted it to go.
  3. In the text file, you'll see the CREATE TABLE statements, that include all the columns and info (basically, the original structure) of your table. Copy that CREATE statement with all that info.
  4. In your MySQL Command, create a new database (CREATE DATABASE database_name). Make it the same name as your original database name.
  5. Create a new table inside the new database--it doesn't have to be the same name as the folder. You can create the new table inside the command prompt, but I created my table in PhpMyAdmin, a free software tool that handles the administration of MySQL over the web. I simply clicked on the database on PhpMyAdmin, then the SQL table, and pasted the table structure from #3. (As a side note, I always received errors if I named my tables "table" in my command prompt, so try to avoid that name).
  6. On your MySQL Command, go into your database, and enter "ALTER TABLE table_name DISCARD TABLESPACE", which will essentially remove this table's .ibd file.
  7. Copy your original table (the table you want to restore)'s .ibd file into the newly-created table to replace the .ibd file that you just removed. Change your initial .ibd file to the newly created table's name. This will mimic the old .ibd file that you just deleted. You can find this folder in the MySQL data folder, under the newly-created database folder on your computer.
  8. Go back to your MySQL Command, go into your database, and enter "ALTER TABLE table_Name IMPORT TABLESPACE." You'll receive a "warning" (1) error-type statement, but just ignore that.
  9. And done! if you try to access your new table, it should contain all the data from your old table.

I hope this helped, and let me know if you have any questions or comments! Also, check out http://www.chriscalender.com/?tag=innodb-error-tablespace-id-in-file for other details.


The main InnoDB data file - usually named ibdata - is essential for you MySQL to be able to understand your .ibd files.

If you need to move data between servers using the binary files, you should stop MySQL cleanly and then move all data files, including the ibdata file(s), between directories.

A more reliable mechanism of moving data between servers on Windows would be to use (mysqldump) or a database export from PHPMyAdmin (or a similar tool).

If binary logging has been enabled the whole time that your server's been running (based on the comments, this may not be the case), you could also use mysqlbinlog to recover every SQL statement you've run on the server from the mysql-bin files, and recreate the database that way. There should be unix timestamps in the mysql-bin files that help you determine how far back they go.

If you've lost your original database files and all you have left are the individual .ibd files, you may have to resort to recovering the data as per akuzminsky's suggestions in the comments.

MySQL 5.6 has some new features for moving InnoDB .ibd data files (transportable tablespaces), but these require some effort and, for a sufficiently small database, it's going to be much easier to transfer data using mysqldump.