myisamchk
database toolsLinux/Unix
The myisamchk command is one of the most frequently used commands in Linux/Unix-like operating systems. myisamchk Check, repair, or optimize MyISAM tables in MySQL databases
Quick Reference
Command Name:
myisamchk
Category:
database tools
Platform:
Linux/Unix
Basic Usage:
myisamchk [options] [arguments]
Common Use Cases
Syntax
myisamchk [options] tbl_name [...]
Options
Option | Description |
---|---|
-?, --help |
Display help and exit |
-a, --analyze |
Analyze distribution of keys |
-b, --backup |
Make a backup of the .MYD file as file-name-time.BAK |
-c, --check |
Check table for errors (default operation) |
-C, --check-only-changed |
Check only tables that have changed since last check |
-d, --description |
Print descriptive information about table |
-e, --extend-check |
Perform extended check |
-f, --force |
Restart with -r if there are any errors in the table |
-F, --fast |
Check only tables that haven't been closed properly |
-i, --information |
Print statistics information about table that is checked |
-k, --keys-used=# |
Define which indexes to update |
-l, --no-symlinks |
Do not follow symbolic links |
-m, --medium-check |
Faster than extended check |
-o, --optimize |
Optimize table |
-p, --parallel-recover |
Use parallel repair with threads |
-q, --quick |
Quick check; don't check rows to see if they link correctly |
-r, --recover |
Can fix almost anything except unique keys |
-s, --silent |
Silent mode; write output only when errors occur |
-S, --sort-index |
Sort index blocks |
-t, --sort-records=# |
Sort records according to a particular index |
-u, --unpack |
Unpack file packed with myisampack |
-v, --verbose |
Print more information |
-w, --wait |
Wait if table is locked |
--character-sets-dir=dir_name |
Directory where character sets are installed |
--correct-checksum |
Correct checksum information for table |
--safe-recover |
Use safe recover; slower than regular recover but can handle some additional cases |
--set-auto-increment[=value] |
Set AUTO_INCREMENT counter |
--tmpdir=path |
Path for temporary files |
Examples
How to Use These Examples
The examples below show common ways to use the myisamchk
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
myisamchk /var/lib/mysql/database/table.MYI