MySQL InnoDB tables corrupt -- how to fix?

34,582

Solution 1

No guarantees, but you may want to look at: https://launchpad.net/percona-data-recovery-tool-for-innodb

Solution 2

even when you use table namespaces, the ibdata1 file still contains data that those namespaces depend on, such as the multiversion index number and the transaction log. you can't just delete that file and expect it to work.

if you're extremely lucky, you can restore/undelete the ibdata1 file and start mysql with the --innodb_force_recovery=3 option. this will allow mysql to start without attempting to rollback/rollforward any transactions.

if you still hav eproblems, you need to post your mysql server log from startup.

Share:
34,582
atp
Author by

atp

Updated on November 05, 2020

Comments

  • atp
    atp over 3 years

    While performing a conditional DELETE operation in one of my InnoDB tables, which apparently required some temporary table to be created in ibdata1, the hard disk filled up and mysql crashed. I couldn't get it to start again until I deleted the ibdata1 file (~30 GB).

    Now mysql starts again, but all the tables in the database seem to be corrupt (when I do a REPAIR TABLE tablename EXTENDED I get:

    +-----------------------------------+--------+----------+---------+
    | Table       | Op     | Msg_type | Msg_text                      |
    +-----------------------------------+--------+----------+---------+
    | mydb.table1 | repair | Error    | Unknown table engine 'InnoDB' |
    | mydb.table1 | repair | error    | Corrupt                       |
    +-----------------------------------+--------+----------+---------+
    

    I was using innodb_file_per_table option so that all of my .frm and .ibd files (which are supposed to contain metadata and data, respectively) are all intact (with the same filesizes they had before the crash), in the directory: /var/mysql/data/mydb/. Does anyone know how I could get mysql to recognize these tables with the appropriate data once again?

    Thanks!

    • northpole
      northpole over 14 years
      did you do a full backup before the corruption?
    • atp
      atp over 14 years
      I only did a backup on table structures (using --no-data) since the rest of the data is enormous, ~100GB and can be repopulated through another script. But I still have these multi-GB .ibd files with respective .frm files, so I think the data is still there. Just not sure how to get MySQL to read it once again.
  • ndeverge
    ndeverge about 12 years
    At a last resort, you can retrieve data directly from the MySQL raw files (experimented users only ;-) Take a look at : ekito.fr/portail/repairing-a-badly-hurt-mysql-database?lang=‌​en