Name

myisamchk

Synopsis

myisamchk options table[.MYI][...]

This utility checks, repairs, and optimizes MyISAM tables. It works with the table files directly and does not require interaction with the MySQL server. Therefore, it may be necessary to specify the path along with the table or table names in the second argument. Also, tables that are being checked should be locked or the MySQL server daemon should be stopped. This utility works with the index files for the tables, so the suffix .MYI may be given for table names to prevent it from attempting to analyze other files. Omitting the suffix (e.g., work_req instead of work_req.*) will have the same effect as giving a specific suffix (work_req.MYI). To check all of the tables in a database, use the wildcard (i.e., *.MYI). Here is a basic example of how you can use myisamchk to check one table:

myisamchk /data/mysql/workrequests/requests
Checking MyISAM file: /data/mysql/workrequests/requests
Data records:     531   Deleted blocks:       0
myisamchk: warning: 3 clients is using or hasn't closed the table properly
- check file-size
- check key delete-chain
- check record delete-chain
- check index reference
- check data record references index: 1
- check record links
MyISAM-table '/data/mysql/workrequests/requests' is usable but should be 
   fixed

No options are specified here, so the default of --check is used. Notice that myisamchk detected a problem with the table. To fix this problem, you can run the utility again, but with the --recover option ...

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.