Question

I am trying to retrieve some data from a mysql table that is marked as crashed. I am working on a restored backup of a machine, so I don't need to worry about anything.

When I try to mysqldump the table (FYI I am using --where to specify which records I need), I get an error:

mysqldump: Got error: 144: Table './[db]/[table]' is marked as crashed and last (automatic?) repair failed when doing LOCK TABLES

If I use --lock-tables=false I get the same error (but failed when doing SHOW FIELDS).

If I try to just SELECT the first record from the table I get the same error.

If I run CHECK TABLE [table], I get the following warnings/errors:

warning  | 1 client is using or hasn't closed the table properly |
warning  | Size of indexfile is: 1991678976      Should be: 1024 |
error    | Record-count is not ok; is 30030697   Should be: 0    |
warning  | Found 141967876 deleted space.   Should be 0          |
warning  | Found 3101578 deleted blocks       Should be: 0       |
warning  | Found 34721783 key parts. Should be: 0                |
error    | Corrupt                                               |

This implies that if I do a repair table, I will lose all the data! There should be 30030697 records there....

Is there any way for me to get to this data?

Was it helpful?

Solution

To repair the table in question issue the command

myisamchk --recover /var/lib/mysql/DATABASENAME/TABLE_NAME.myi

(Where DATABASENAME is the name of the database you are working with and TABLE_NAME is the name of the table to be checked.)

If this does not fully recover the table, you can re-run the command replacing –recover with –safe-recover which is slower and more thorough.

They only take a dump like that if there was some serious conflict during a row level lock, or bad write (bad sector).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top