Case: Ibdata1 file is missing. Only .frm and .ibd files remain. 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.
Install dbsake:
$ curl -s get.dbsake.net > dbsake $ chmod u+x dbsake
(step-1) First, you must generate CREATE TABLE statements from .frm file
$ dbsake frmdump table_name.frm > table_name.txt
(step-2) In the text file table_name.txt, 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.
(step-3) In your MySQL Command, create a new database (CREATE DATABASE database_name). Execute the CREATE TABLE statements you just created (step-2)
Run mysql command
ALTER TABLE TABLE_NAME DISCARD TABLESPACE;
(step-4) 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.
Then run mysql command
ALTER TABLE TABLE_NAME IMPORT TABLESPACE;
Repeat all steps for all tables that you want to restore.
And done! if you try to access your new table, it should contain all the data from your old table.