I'm working on a project at home and learning databases as I go. Because of my inexperience I've just learned the hard way that cut/pasting .ibd files is an extremely bad idea. The tables have disconnected from the database and I'm trying to recover them using the methods suggested previously (ie. https://hoststud.com/resources/steps-to-restoring-table-structure-from-frm-and-ibd-files.465/ and http://www.chriscalender.com/tag/innodb-error-tablespace-id-in-file/) but I'm stuck getting the CREATE TABLE details from the .frm files. I've spent so much time building all the tables I'd rather not start from scratch.

Using mysqlfrm to read the files by spawning a server I got this response:

ERROR: Failed to correctly read the .frm file. Please try reading the file with the --diagnostic mode.

So obediently running the --diagnostic command instead I got this response:

mysqluc> mysqlfrm --server=root:pass@localhost:3306 D:/Databases/MariaDB/smt_a100/actions.frm --diagnostic -vvv
WARNING: Using a password on the command line interface can be insecure.
# Source on localhost: ... connected.
# CAUTION: The diagnostic mode is a best-effort parse of the .frm file. As such, it may not identify all of the components of the table correctly. This is especially true for damaged files. It will also not read the default values for the columns and the resulting statement may not be syntactically correct.
# Reading .frm file for D:/Databases/MariaDB/smt_a100/actions.frm:
# The .frm file is a TABLE.
# Skipping to header at : 2
# General Data from .frm file:
{'IO_SIZE': 86,
 'MYSQL_VERSION_ID': 100315,
 'avg_row_length': 0,
 'charset_low': 0,
 'create_options': 9,
 'db_create_pack': 2,
 'default_charset': 45,
 'default_part_eng': 0,
 'extra_size': 16,
 'frm_file_ver': 5,
 'frm_version': 10,
 'key_block_size': 0,
 'key_info_length': 33,
 'key_length': 505,
 'legacy_db_type': 'INNODB',
 'length': 1113,
 'max_rows': 0,
 'min_rows': 0,
 'rec_length': 162,
 'row_type': 0,
 'table_charset': 45,
 'tmp_key_length': 505}
# Skipping to key data at : 56
# Reading key part 0.
# Index (key) Data from .frm file:
{'key_names': ['PRIMARY'],
 'keys': [{'algorithm': 0,
           'block_size': 0,
           'comment': '',
           'flags': 0,
           'key_length': 1,
           'key_parts': [{'field_num': 1,
                          'key_part_flag': 0,
                          'key_type': 2560,
                          'length': 1,
                          'offset': 0}],
           'num_parts': 1}],
 'num_key_parts': (1,),
 'num_keys': 1}
# Skipping to default data at : 250
# Skipping to keys at : 2f3
# Engine string: InnoDB
# Partition string:
# Skipping to column data at : 45e
EXCEPTION: unpack requires a string argument of length 26
ERROR: Cannot read column header.

Execution of utility: 'mysqlfrm --server=root:pass@localhost:3306 D:/Databases/MariaDB/smt_a100/actions.frm --diagnostic -vvv' ended with return code '1' but no error message was streamed to the standard error, please review the output from its execution.

From other tables I get similar responses with different required string lengths.

My question is how to I get around this exception and finally get the CREATE TABLE code?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.