简体   繁体   中英

mysql innodb currupted table

I am using MySQL 5.1.68. Recently a table of my database has been corrupted due to improper input. I have tried to dump the table and change the innodb_force_recovery but none of them worked. The table indices are not corrupted. The problem occurred at a string column where ',' characters has been input. I know the row where the corruption has started and I do not care if data from that row and below will be deleted. Can I manually delete those records from the ibdata file? is there another approach?

You can use mysqldump to dump part of a table. For example, if you want to dump rows of table foo up to primary key value 1234 but no further:

$ mysqldump mydatabase foo --where "id <= 1234" > foo-dump.sql

Then drop table foo, hoping that removes the corruption. Then restore the dump file.


Comment from @akuzmisnky is correct (he's a colleague of mine at Percona, and he's one of the most experienced experts on MySQL data recovery in the world).

Here's the sequence of actions he is referring to, in more detail:

  1. Dump as much data as you can without touching the corrupted parts of your database. This may take some experimentation. Dump all your InnoDB data from non-corrupted tables too.
  2. Stop mysqld.
  3. rm the InnoDB tablespaces and log files.
  4. Start mysql.
  5. Restore the dump files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM