MySQL DBA - Tips and Techniques Magazine

14 Oct 2014

MyISAM Table Corruption ( Check and Fix )

1)     Get enough information from your error  email(server name and corrupted table)

2)     login as yourself (using keys) – e.g. mraj

3)     sudo bash ( become root user)

4)     Check Table for corruption :

 

4a) From Command line(logged in as root)

- mysqlcheck –uroot –p[password] [databasename] tablename

 

            or

 

4b) From inside MYSQL

-        mysql -uroot –p[password]

-        use [databasename];

-        check table [tablename];

 

e.g. should give you similar output

+--------------+-------+----------+----------------------------------------------------------+

| Table        | Op    | Msg_type | Msg_text                                                 |

+--------------+-------+----------+----------------------------------------------------------+

| ebms.message | check | warning  | Table is marked as crashed                               |

| ebms.message | check | error    | Found 3138852 keys of 3138848                            |

| ebms.message | check | error    | Corrupt                                                  |

+--------------+-------+----------+----------------------------------------------------------+

 

 

5)     Repair Table

 

Using MYSQL to repair the above table called 'message':

 

-        mysql -uroot –p[password]

-        use [databasename];

-        mysql> repair table message

 

+--------------+--------+----------+----------+

| Table        | Op     | Msg_type | Msg_text |

+--------------+--------+----------+----------+

| ebms.message | repair | status   | OK       |

+--------------+--------+----------+----------+

1 row in set (1 min 14.83 sec)

 

6)     Check Table again for corruption, follow step 4a or 4b.


 


No comments:

Post a Comment