8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 9 备份与恢复 / 9.6 MyISAM 表维护和崩溃恢复 / 9.6.2 如何检查 MyISAM 表是否有错误
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

9.6.2 如何检查 MyISAM 表的错误9.6.2 How to Check MyISAM Tables for Errors

要检查一个 MyISAM 表,请使用以下命令:To check a MyISAM table, use the following commands:

  • myisamchk tbl_namemyisamchk tbl_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 -m tbl_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 -e tbl_name

    这会对所有数据进行完整而彻底的检查(-e 意味着 “扩展检查”)。它会对每一行的每个键进行检查读取,以验证它们确实指向正确的行。对于有许多索引的大表,这可能需要很长时间。通常,myisamchk 在发现第一个错误后会停止。如果你想获得更多信息,可以添加 -v(详细)选项。这会使 myisamchk 继续运行,最多处理 20 个错误。This does a complete and thorough check of all data (-e means “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 -i tbl_name

    这与前面的命令类似,但 -i 选项告诉 myisamchk 打印额外的统计信息。This is like the previous command, but the -i option 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.