This answer works if you happen to get lucky and guess all the correct options, but how would you know that the file format needs to be Barracuda, and the KEY_BLOCK_SIZE should be 4?
In particular the command:
od -t x1 -j 54 -N 4 tryme.ibd
The result is:
0000066 00 00 00 27
0000072
The 27 is what you’re looking for, it’s a number that describes the file format and options.
By creating innodb tables with different options, and then running the hex dump on the resulting ibd file, you can find a create table statement that you *know* will match the orhpan .ibd file you have.
Also, don’t forget IMPORT TABLESPACE and DISCARD tablespace. This is a better way to handle the .ibd file than doing this on the filesystem because this method would only work if this table was the first one you created in innodb (or worse, the Nth) Using the tablespace commands will give you some additional information in the error logs on failure which will increase your chances of getting it right.
Vadim
July 2nd, 2009
Gavin,
You may see see that different KEY_BLOCK_SIZE needed (and therefore Barracuda format) by initial file size of table. Usually empty InnoDB table takes 92K, but file I proposed was 64K
This answer works if you happen to get lucky and guess all the correct options, but how would you know that the file format needs to be Barracuda, and the KEY_BLOCK_SIZE should be 4?
The innodb manual gives some good info for exploring ibd file: http://www.innodb.com/doc/innodb_plugin-1.0/innodb-file-format.html#innodb-file-format-identifying
In particular the command:
od -t x1 -j 54 -N 4 tryme.ibd
The result is:
0000066 00 00 00 27
0000072
The 27 is what you’re looking for, it’s a number that describes the file format and options.
By creating innodb tables with different options, and then running the hex dump on the resulting ibd file, you can find a create table statement that you *know* will match the orhpan .ibd file you have.
Also, don’t forget IMPORT TABLESPACE and DISCARD tablespace. This is a better way to handle the .ibd file than doing this on the filesystem because this method would only work if this table was the first one you created in innodb (or worse, the Nth) Using the tablespace commands will give you some additional information in the error logs on failure which will increase your chances of getting it right.
Gavin,
You may see see that different KEY_BLOCK_SIZE needed (and therefore Barracuda format) by initial file size of table. Usually empty InnoDB table takes 92K, but file I proposed was 64K