myisamchk — MyISAM Table-Maintenance Utility

Rate this post
  • 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

 

Related Posts

  • 50
    If you have to restore MyISAM tables that have become corrupt, try to recover them using REPAIR TABLE  or myisamchk -r That should work in 99.9% of all cases. In this article we will cover to repair/recover MyISAM tables using myisamchk. MyISAM tables have .MYD and .MYI  files for storing data…
    Tags: myisamchk, table, tables, check, myisam, mysql
  • 42
      To rename a table in MySQL you just need to run a command named RENAME TABLE, the syntax is very easy to use. RENAME TABLE table1 TO table2; The RENAME TABLE command will rename the table atomically, which means your table will be locked during the command. You can…
    Tags: table, mysql, tutorial
  • 40
    MySQL SUBSTRING() returns a specified number of characters from a particular position of a given string. Syntax: SUBSTRING(str, pos, len) or SUBSTRING(str FROM pos FOR len) Arguments Name       Description str              A string. pos             Starting position.…
    Tags: mysql, tutorial, database, learn
  • 34
    Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d Error #1064 means that MySQL can't understand your command. To fix it: Read the error message. It tells you exactly where in your command MySQL got confused. Check the manual. By comparing against what MySQL expected at that…
    Tags: mysql, check, tutorial
  • 31
      In the backup script the views are first created as tables which are then dropped at the end of the script as each view is being created, so it seems that an error occurs while creating the views at the end of the script. However when a view is…
    Tags: database, tables, mysql, table

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: