subject: Repair Myisam Tables By Myisamchk Command [print this page] There are two types of storage engine used by the MySQL database, one is MyISAM and another is InnoDB. By default MySQL uses MyISAM as a storage engine. Records store in the form of table in the MyISAM. The MyISAM table gets damaged or corrupted very easily by the several reasons, like virus infection, power failure, software malfunction, hardware failure or human errors. In this article, i will explain how to use myisamchk command to identify and solve the table corruption in MyISAM storage engine.
When you create a table in the MySQL database, it creates three other different files, which are given below:
.frm File: To save the table format.
.MYD File: To save the data of MySQL. It is also known as MyData file.
.MYI File: To save the index of MySQL database. It is also known as MyIndex file.
Consider a practicle scenario wherein you found attached data files gets corrupted and need to repair them.
undef error - DBD::mysql::db selectrow_array failed: Table 'attach_data' is
marked as crashed and should be repaired [for Statement "SELECT LENGTH(thedata)
FROM attach_data WHERE id = ?"] at Bugzilla/Attachment.pm line 344
Bugzilla::Attachment::datasize('Bugzilla::Attachment=HASH(0x9df119c)') called
The above error message shows that the attached data gets corrupted and need to repair mysql database and fix the problem.
Solution: For resolving above error message, you have to follow some steps which is given below:
1. Identify all corrupted MyISAM tables by myisamchk command: