myisamchk — MyISAM Table-Maintenance Utility

  • The myisamchk utility gets information about your database tables or checks, repairs, or optimizes them.
  • myisamchk works with MyISAM tables (tables that have .MYD and .MYI files for storing data and indexes).
  • The use of myisamchk with partitioned tables is not supported.

 

How to run this Utility – myisamchk 

myisamchk [options] tbl_name

  • The options specify what you want myisamchk to do.  
  • You can also get a list of options by invoking myisamchk –help
  • With no options, myisamchk simply checks your table as the default operation
  • tbl_name is the database table you want to check or repair.
  • If you run myisamchk somewhere other than in the database directory, you must specify the path to the database directory, because myisamchk has no idea where the database is located.
  • In fact, myisamchk does not actually care whether the files you are working on are located in a database directory.
  • You can copy the files that correspond to a database table into some other location and perform recovery operations on them there.

 

You can name several tables on the myisamchk command line if you wish.

You can also specify a table by naming its index file (the file with the .MYI suffix).

This enables you to specify all tables in a directory by using the pattern *.MYI.

Let’s have some example

myisamchk *.MYI

If you are not in the database directory, you can check all the tables there by specifying the path to the directory:

myisamchk /path/to/database_dir/*.MYI

You can even check all tables in all databases by specifying a wildcard with the path to the MySQL data directory:

myisamchk /path/to/datadir/*/*.MYI

 

Leave a Reply