要检查一个 MyISAM 表,请使用以下命令:To check a MyISAM table, use the following
commands:
myisamchk
tbl_namemyisamchktbl_name这可以发现 99.99% 的所有错误。它无法发现的是仅涉及 数据文件 的损坏(这种情况非常少见)。如果你想检查一张表,通常应该运行 myisamchk,不使用选项或使用
-s(静默)选项。This finds 99.99% of all errors. What it cannot find is corruption that involves only the data file (which is very unusual). If you want to check a table, you should normally run myisamchk without options or with the-s(silent) option.myisamchk -m
tbl_namemyisamchk -mtbl_name这可以发现 99.999%的所有错误。它首先检查所有索引条目是否有错误,然后读取所有行。它会计算行中所有键值的校验和,并验证该校验和是否与索引树中键的校验和匹配。This finds 99.999% of all errors. It first checks all index entries for errors and then reads through all rows. It calculates a checksum for all key values in the rows and verifies that the checksum matches the checksum for the keys in the index tree.
myisamchk -e
tbl_namemyisamchk -etbl_name这会对所有数据进行完整而彻底的检查(
-e意味着 “扩展检查”)。它会对每一行的每个键进行检查读取,以验证它们确实指向正确的行。对于有许多索引的大表,这可能需要很长时间。通常,myisamchk 在发现第一个错误后会停止。如果你想获得更多信息,可以添加-v(详细)选项。这会使 myisamchk 继续运行,最多处理 20 个错误。This does a complete and thorough check of all data (-emeans “extended check”). It does a check-read of every key for each row to verify that they indeed point to the correct row. This may take a long time for a large table that has many indexes. Normally, myisamchk stops after the first error it finds. If you want to obtain more information, you can add the-v(verbose) option. This causes myisamchk to keep going, up through a maximum of 20 errors.myisamchk -e -i
tbl_namemyisamchk -e -itbl_name这与前面的命令类似,但
-i选项告诉 myisamchk 打印额外的统计信息。This is like the previous command, but the-ioption tells myisamchk to print additional statistical information.
在大多数情况下,一个简单的 myisamchk 命令,仅包含表名参数,就足以检查一个表。In most cases, a simple myisamchk command with no arguments other than the table name is sufficient to check a table.