How to recover an orphaned .ibd file with MySQL 5.6

November 5, 2013
Author
Michael Rikmas
Share this Post:

A few years ago Yves Trudeau and Aleksandr Kuzminsky wrote posts about different ways for recovering orphaned .ibd files:

Today I want to show you how to do that in a more easy and quick way. In my example, I’ll restore a “payment.ibd” file (payment table) from Sakila DB on a server with MySQL 5.5 (but with help from MySQL 5.6 and sandbox).

In my case the OS is CentOS. So I needed to:
install mysqlsandbox(check instructions there)
download latest Percona Server 5.6:

create sandbox

test it

It Works!

check datadir and if the innodb_file_per_table option enabled (this is a requirement)

If it’s not enabled then you’ll need to enable it

create empty payment table on 5.6 sandbox

payment_table.sql – is file with “SHOW CREATE TABLE” statement for payment table. The table structure should be the same.

stop sandbox

replace .ibd file (in my case the correct copy of it is located in my homedir)

make sure permissions are ok for .ibd file

start sandbox

Currently, if you’ll try to select something from the table you’ll get an error:

select from table

error log

How to Fix it? In 5.6 tablespace management is very improved so the only thing needed is “ALTER TABLE .. DISCARD TABLESPACE” and “ALTER TABLE .. IMPORT TABLESPACE”.

Please check also limitations: Tablespace Copying Limitations

Look at an example:

Discard tablespace

Import tablespace

That’s it, data recovered, payment table accessible on 5.6 sandbox.

Now check if data exists in payment table on sandbox:

Exists.

So dump it from sandbox and restore on 5.5:

dump from 5.6

restore to 5.5

Check if data exists on 5.5

During my work with this case, I got into a situation in which the drop table payment on 5.5 wasn’t possible because of payment.idb there wasn’t correct – so the server crashed each time I tried to access this table. The workaround is:
– stop server
– rm .ibd file
– start server
– drop table as usually by DROP TABLE command

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved