mysqlcheck 客户端执行表维护:它检查、修复、优化或分析表。The mysqlcheck client performs table maintenance: It checks, repairs, optimizes, or analyzes tables.
每个表都被锁定,因此在处理过程中对其他会话不可用,但对于检查操作,表会使用仅 READ 锁(有关 READ 和 WRITE 锁的更多信息,请参阅第 15.3.6 节“LOCK TABLES 和 UNLOCK TABLES 语句”)。表维护操作可能非常耗时,尤其是对于大型表。如果您使用 --databases 或 --all-databases 选项来处理一个或多个数据库中的所有表,则调用 mysqlcheck 可能需要很长时间。 (如果 MySQL 升级过程确定需要表检查,则也是如此,因为它以相同的方式处理表。)Each table is locked and therefore unavailable to other sessions
while it is being processed, although for check operations, the
table is locked with a READ lock only (see
Section 15.3.6, “LOCK TABLES and UNLOCK TABLES Statements”, for more information about
READ and WRITE locks).
Table maintenance operations can be time-consuming, particularly
for large tables. If you use the
--databases or
--all-databases option to
process all tables in one or more databases, an invocation of
mysqlcheck might take a long time. (This is
also true for the MySQL upgrade procedure if it determines that
table checking is needed because it processes tables the same
way.)
mysqlcheck 必须在 mysqld 服务器运行时使用,这意味着您不必停止服务器即可执行表维护。mysqlcheck must be used when the mysqld server is running, which means that you do not have to stop the server to perform table maintenance.
mysqlcheck 使用 SQL 语句 CHECK TABLE、REPAIR TABLE、ANALYZE TABLE 和 OPTIMIZE TABLE 以方便用户的方式。它确定要执行的操作使用哪些语句,然后将语句发送到服务器来执行。有关每个语句适用于哪些存储引擎的详细信息,请参阅第 15.7.3 节“表维护语句”中这些语句的说明。mysqlcheck uses the SQL statements
CHECK TABLE,
REPAIR TABLE,
ANALYZE TABLE, and
OPTIMIZE TABLE in a convenient
way for the user. It determines which statements to use for the
operation you want to perform, and then sends the statements to
the server to be executed. For details about which storage
engines each statement works with, see the descriptions for
those statements in
Section 15.7.3, “Table Maintenance Statements”.
并非所有存储引擎都必然支持所有四种维护操作。在这种情况下,将显示错误信息。例如,如果 test.t 是一个 MEMORY 表,尝试检查它会产生以下结果:All storage engines do not necessarily support all four
maintenance operations. In such cases, an error message is
displayed. For example, if test.t is an
MEMORY table, an attempt to check it produces
this result:
$> mysqlcheck test t
test.t
note : The storage engine for the table doesn't support check
如果mysqlcheck 无法修复表,请参阅第 3.14 节“重建或修复表或索引”手动表修复策略的索引”。例如,InnoDB 表就是这种情况,可以使用 CHECK TABLE 检查,但不能使用 REPAIR TABLE。If mysqlcheck is unable to repair a table,
see Section 3.14, “Rebuilding or Repairing Tables or Indexes” for manual table repair
strategies. This is the case, for example, for
InnoDB tables, which can be checked with
CHECK TABLE, but not repaired
with REPAIR TABLE.
在执行表修复操作之前,最好先备份表;在某些情况下,该操作可能会导致数据丢失。可能的原因包括但不限于文件系统错误。It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to file system errors.
有三种通用方法可以调用 mysqlcheck:There are three general ways to invoke mysqlcheck:
mysqlcheck [options]db_name[tbl_name...] mysqlcheck [options] --databasesdb_name... mysqlcheck [options] --all-databases
如果在 db_name 后不指定任何表,或者使用 --databases 或 --all-databases 选项,将检查整个数据库。If you do not name any tables following
db_name or if you use the
--databases or
--all-databases option,
entire databases are checked.
mysqlcheck 与其他客户端程序相比,它有一个特殊功能。检查表的默认行为(--check)可以通过重命名二进制文件来更改。如果你想要一个默认修复表的工具,你应该只复制mysqlcheck,命名为mysqlrepair,或者创建一个到mysqlcheck,名为mysqlrepair。如果您调用mysqlrepair,它将修复表。mysqlcheck has a special feature compared to
other client programs. The default behavior of checking tables
(--check) can be changed by
renaming the binary. If you want to have a tool that repairs
tables by default, you should just make a copy of
mysqlcheck named
mysqlrepair, or make a symbolic link to
mysqlcheck named
mysqlrepair. If you invoke
mysqlrepair, it repairs tables.
下表中显示的名称可用于更改mysqlcheck 默认行为。The names shown in the following table can be used to change mysqlcheck default behavior.
| 命令Command | 意义Meaning |
|---|---|
| mysqlrepair | 默认选项是 --repairThe default option is --repair |
| mysqlanalyze | 默认选项是 --analyzeThe default option is --analyze |
| mysql 优化mysqloptimize | 默认选项是 --optimizeThe default option is --optimize |
mysqlcheck 支持以下选项,这些选项可以在命令行上指定,也可以在选项文件的 [mysqlcheck] 和 [client] 组中指定。有关 MySQL 程序使用的选项文件的信息,请参见 第 6.2.2.2 节,“使用选项文件”。mysqlcheck supports the following options,
which can be specified on the command line or in the
[mysqlcheck] and [client]
groups of an option file. For information about option files
used by MySQL programs, see Section 6.2.2.2, “Using Option Files”.
表 6.12 mysqlcheck 选项Table 6.12 mysqlcheck Options
| 选项名称Option Name | 说明Description |
|---|---|
| --所有数据库--all-databases | 检查所有数据库中的所有表Check all tables in all databases |
| --全部合一--all-in-1 | 为每个数据库执行一条语句,列出该数据库中的所有表Execute a single statement for each database that names all the tables from that database |
| --分析--analyze | 分析表格Analyze the tables |
| --自动修复--auto-repair | 如果已检查的表损坏,自动修复它If a checked table is corrupted, automatically fix it |
| --绑定地址--bind-address | 使用指定的网络接口连接到 MySQL 服务器Use specified network interface to connect to MySQL Server |
| --字符集目录--character-sets-dir | 安装字符集的目录Directory where character sets are installed |
| --检查--check | 检查表格中的错误Check the tables for errors |
| --仅检查已更改的--check-only-changed | 仅检查自上次检查以来有变化的表Check only tables that have changed since the last check |
| --check-upgrade 检查升级--check-upgrade | 使用 FOR UPGRADE 选项调用 CHECK TABLEInvoke CHECK TABLE with the FOR UPGRADE option |
| --压缩--compress | 压缩客户端和服务器之间发送的所有信息Compress all information sent between client and server |
| --压缩算法--compression-algorithms | 允许用于连接服务器的压缩算法Permitted compression algorithms for connections to server |
| --数据库--databases | 将所有参数解释为数据库名称Interpret all arguments as database names |
| --调试--debug | 写调试日志Write debugging log |
| --调试检查--debug-check | 程序退出时打印调试信息Print debugging information when program exits |
| --调试信息--debug-info | 在程序退出时打印调试信息、内存和 CPU 统计信息Print debugging information, memory, and CPU statistics when program exits |
| --默认认证--default-auth | 要使用的身份验证插件Authentication plugin to use |
| --默认字符集--default-character-set | 指定默认字符集Specify default character set |
| --额外默认文件--defaults-extra-file | 除了常规选项文件外,读取指定名称的选项文件Read named option file in addition to usual option files |
| --默认文件--defaults-file | 仅读取指定的选项文件Read only named option file |
| --默认组后缀--defaults-group-suffix | 选项组后缀值Option group suffix value |
| --启用明文插件--enable-cleartext-plugin | 启用明文身份验证插件Enable cleartext authentication plugin |
| --扩展--extended | 检查并修复表格Check and repair tables |
| --快速--fast | 仅检查未正确关闭的表格Check only tables that have not been closed properly |
| --强制--force | 即使发生 SQL 错误也继续Continue even if an SQL error occurs |
| --获取服务器公钥--get-server-public-key | 从服务器请求 RSA 公钥Request RSA public key from server |
| --帮助--help | 显示帮助信息并退出Display help message and exit |
| --主机--host | MySQL 服务器所在的主机Host on which MySQL server is located |
| --登录路径--login-path | 从 .mylogin.cnf 读取登录路径选项Read login path options from .mylogin.cnf |
| --中等检查--medium-check | 执行比 --extended 操作更快的检查Do a check that is faster than an --extended operation |
| --无默认值--no-defaults | 不读取任何选项文件Read no option files |
| --无登录路径--no-login-paths | 不要从登录路径文件中读取登录路径Do not read login paths from the login path file |
| --优化--optimize | 优化表格Optimize the tables |
| --密码--password | 连接服务器时使用的密码Password to use when connecting to server |
| --密码 1--password1 | 首次多因素身份验证密码,用于连接服务器First multifactor authentication password to use when connecting to server |
| --密码 2--password2 | 连接服务器时使用的第二个多因素认证密码Second multifactor authentication password to use when connecting to server |
| --密码 3--password3 | 连接服务器时使用的第三个多因素认证密码Third multifactor authentication password to use when connecting to server |
| --管道--pipe | 使用命名管道连接到服务器(仅限 Windows)Connect to server using named pipe (Windows only) |
| --插件目录--plugin-dir | 插件安装的目录Directory where plugins are installed |
| --端口--port | 连接的 TCP/IP 端口号TCP/IP port number for connection |
| --打印默认值--print-defaults | 打印默认选项Print default options |
| --协议--protocol | 要使用的传输协议Transport protocol to use |
| --快速--quick | 检查的最快方法The fastest method of checking |
| --repair 修复--repair | 执行一种几乎可以修复任何东西的修复,除了那些不唯一的唯一键Perform a repair that can fix almost anything except unique keys that are not unique |
| --服务器公钥路径--server-public-key-path | 包含 RSA 公钥的文件路径名称Path name to file containing RSA public key |
| --共享内存基础名称--shared-memory-base-name | 共享内存连接的共享内存名称(仅限 Windows)Shared-memory name for shared-memory connections (Windows only) |
| --静默--silent | 静音模式Silent mode |
| --跳过数据库--skip-database | 在执行操作时省略此数据库Omit this database from performed operations |
| --套接字--socket | 要使用的 Unix 套接字文件或 Windows 命名管道Unix socket file or Windows named pipe to use |
| --SSL CA 证书--ssl-ca | 包含受信任的 SSL 证书颁发机构列表的文件File that contains list of trusted SSL Certificate Authorities |
| --SSL CA 路径--ssl-capath | 包含受信任的 SSL 证书颁发机构证书文件的目录Directory that contains trusted SSL Certificate Authority certificate files |
| --SSL 证书--ssl-cert | 包含 X.509 证书的文件File that contains X.509 certificate |
| --SSL 加密套件--ssl-cipher | 连接加密的允许密码Permissible ciphers for connection encryption |
| --ssl-crl | 包含证书吊销列表的文件File that contains certificate revocation lists |
| --ssl-crl 路径--ssl-crlpath | 包含证书吊销列表文件的目录Directory that contains certificate revocation-list files |
| --ssl-fips 模式--ssl-fips-mode | 是否在客户端启用 FIPS 模式Whether to enable FIPS mode on client side |
| --ssl 密钥--ssl-key | 包含 X.509 密钥的文件File that contains X.509 key |
| --ssl 模式--ssl-mode | 与服务器连接的期望安全状态Desired security state of connection to server |
| --ssl 会话数据--ssl-session-data | 包含 SSL 会话数据的文件File that contains SSL session data |
| --ssl 会话数据在重用失败时继续--ssl-session-data-continue-on-failed-reuse | 如果会话重用失败,是否建立连接Whether to establish connections if session reuse fails |
| --表--tables | 覆盖 --databases 或 -B 选项Overrides the --databases or -B option |
| --tls 密码套件--tls-ciphersuites | 允许的用于加密连接的 TLSv1.3 加密套件Permissible TLSv1.3 ciphersuites for encrypted connections |
| --TLS SNI 服务器名--tls-sni-servername | 由客户端提供的服务器名称Server name supplied by the client |
| --TLS 版本--tls-version | 允许用于加密连接的 TLS 协议Permissible TLS protocols for encrypted connections |
| --use-frm | 用于 MyISAM 表的修复操作For repair operations on MyISAM tables |
| --用户--user | 连接服务器时使用的 MySQL 用户名MySQL user name to use when connecting to server |
| --详细--verbose | 详细模式Verbose mode |
| --版本--version | 显示版本信息并退出Display version information and exit |
| --写入二进制日志--write-binlog | 将 ANALYZE、OPTIMIZE、REPAIR 语句记录到二进制日志。--skip-write-binlog 会向这些语句添加 NO_WRITE_TO_BINLOGLog ANALYZE, OPTIMIZE, REPAIR statements to binary log. --skip-write-binlog adds NO_WRITE_TO_BINLOG to these statements |
| --zstd-压缩等级--zstd-compression-level | 用于与服务器进行 zstd 压缩连接的压缩级别Compression level for connections to server that use zstd compression |
--help,-?命令行格式Command-Line Format --help--help显示帮助信息并退出。Display a help message and exit.
--all-databases,-A命令行格式Command-Line Format --all-databases检查所有数据库中的所有表。这与使用
--databases选项并在命令行中列出所有数据库相同,只是INFORMATION_SCHEMA和performance_schema数据库不会被检查。可以通过使用--databases选项显式指定这些数据库来检查它们。Check all tables in all databases. This is the same as using the--databasesoption and naming all the databases on the command line, except that theINFORMATION_SCHEMAandperformance_schemadatabases are not checked. They can be checked by explicitly naming them with the--databasesoption.--all-in-1,-1命令行格式Command-Line Format --all-in-1不要为每个表发出一条语句,而是为每个数据库执行一条语句,该语句列出要处理的该数据库中的所有表。Instead of issuing a statement for each table, execute a single statement for each database that names all the tables from that database to be processed.
--analyze,-a命令行格式Command-Line Format --analyze--analyze分析这些表格。Analyze the tables.
命令行格式Command-Line Format --auto-repair--auto-repair如果检查过的表格损坏,则自动修复它。所有必要的修复将在检查完所有表格后进行。If a checked table is corrupted, automatically fix it. Any necessary repairs are done after all tables have been checked.
命令行格式Command-Line Format --bind-address=ip_address--bind-address=ip_address在具有多个网络接口的计算机上,使用此选项选择用于连接到 MySQL 服务器的接口。On a computer having multiple network interfaces, use this option to select which interface to use for connecting to the MySQL server.
命令行格式Command-Line Format --character-sets-dir=dir_name--character-sets-dir=dir_name类型Type 目录名称Directory name 安装字符集的目录。请参见第 12.15 节,“字符集配置”。The directory where character sets are installed. See Section 12.15, “Character Set Configuration”.
--check,-c命令行格式Command-Line Format --check检查表格中的错误。这是默认操作。Check the tables for errors. This is the default operation.
命令行格式Command-Line Format --check-only-changed仅检查自上次检查以来已更改或未正确关闭的桌子。Check only tables that have changed since the last check or that have not been closed properly.
--check-upgrade,-g命令行格式Command-Line Format --check-upgrade--check-upgrade使用
CHECK TABLE并带上FOR UPGRADE选项来检查表是否与当前服务器版本不兼容。InvokeCHECK TABLEwith theFOR UPGRADEoption to check tables for incompatibilities with the current version of the server.命令行格式Command-Line Format --compress[={OFF|ON}]--compress[={OFF|ON}]已弃用Deprecated 是Yes 类型Type 布尔Boolean 默认值Default Value OFFOFF如果可能,压缩客户端与服务器之间发送的所有信息。参见 第 6.2.8 节,“连接压缩控制”。Compress all information sent between the client and the server if possible. See Section 6.2.8, “Connection Compression Control”.
此选项已被弃用。预计将在 MySQL 的未来版本中移除。请参阅 配置遗留连接压缩。This option is deprecated. Expect it to be removed in a future version of MySQL. See Configuring Legacy Connection Compression.
--compression-algorithms=value--compression-algorithms=value命令行格式Command-Line Format --compression-algorithms=value--compression-algorithms=value类型Type 设置Set 默认值Default Value uncompresseduncompressed有效值Valid Values zlibzstduncompresseduncompressed允许用于与服务器连接的压缩算法。可用算法与
protocol_compression_algorithms系统变量的算法相同。默认值为uncompressed。The permitted compression algorithms for connections to the server. The available algorithms are the same as for theprotocol_compression_algorithmssystem variable. The default value isuncompressed.更多信息,请参阅 第 6.2.8 节,“连接压缩控制”。For more information, see Section 6.2.8, “Connection Compression Control”.
--databases,-B--databases,-B命令行格式Command-Line Format --databases--databases处理指定数据库中的所有表。通常,mysqlcheck 将命令行上的第一个参数视为数据库名,任何后续参数视为表名。使用此选项时,它将所有名称参数视为数据库名。Process all tables in the named databases. Normally, mysqlcheck treats the first name argument on the command line as a database name and any following names as table names. With this option, it treats all name arguments as database names.
--debug[=debug_options],-# [debug_options]--debug[=,debug_options]-# [debug_options]命令行格式Command-Line Format --debug[=debug_options]--debug[=debug_options]类型Type 字符串String 默认值Default Value d:t:o写入调试日志。典型的
debug_options字符串是d:t:o,。默认值是file_named:t:o。Write a debugging log. A typicaldebug_optionsstring isd:t:o,. The default isfile_named:t:o.此选项仅在 MySQL 使用
WITH_DEBUG构建时可用。Oracle 提供的 MySQL 发行版二进制文件 未 使用此选项构建。This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle are not built using this option.命令行格式Command-Line Format --debug-check类型Type 布尔Boolean 默认值Default Value FALSE程序退出时打印一些调试信息。Print some debugging information when the program exits.
此选项仅在 MySQL 使用
WITH_DEBUG构建时可用。Oracle 提供的 MySQL 发行版二进制文件 未 使用此选项构建。This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle are not built using this option.命令行格式Command-Line Format --debug-info类型Type 布尔Boolean 默认值Default Value FALSE在程序退出时打印调试信息以及内存和 CPU 使用情况统计。Print debugging information and memory and CPU usage statistics when the program exits.
此选项仅在 MySQL 使用
WITH_DEBUG构建时可用。Oracle 提供的 MySQL 发行版二进制文件 未 使用此选项构建。This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle are not built using this option.--default-character-set=charset_name--default-character-set=charset_name命令行格式Command-Line Format --default-character-set=charset_name--default-character-set=charset_name类型Type 字符串String 使用
charset_name作为默认字符集。请参见 第 12.15 节,“字符集配置”。Usecharset_nameas the default character set. See Section 12.15, “Character Set Configuration”.--defaults-extra-file=file_name--defaults-extra-file=file_name命令行格式Command-Line Format --defaults-extra-file=file_name--defaults-extra-file=file_name类型Type 文件名File name 在全局选项文件之后读取此选项文件,但(在 Unix 系统上)在用户选项文件之前。如果该文件不存在或无法访问,将发生错误。如果
file_name不是绝对路径名,则相对于当前目录解释。Read this option file after the global option file but (on Unix) before the user option file. If the file does not exist or is otherwise inaccessible, an error occurs. Iffile_nameis not an absolute path name, it is interpreted relative to the current directory.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--defaults-file=file_name--defaults-file=file_name命令行格式Command-Line Format --defaults-file=file_name--defaults-file=file_name类型Type 文件名File name 仅使用指定的选项文件。如果文件不存在或无法访问,将会发生错误。如果
file_name不是绝对路径名,则将其相对于当前目录解释。Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. Iffile_nameis not an absolute path name, it is interpreted relative to the current directory.例外:即使使用
--defaults-file,客户端程序仍会读取.mylogin.cnf。Exception: Even with--defaults-file, client programs read.mylogin.cnf.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--defaults-group-suffix=str--defaults-group-suffix=str命令行格式Command-Line Format --defaults-group-suffix=str--defaults-group-suffix=str类型Type 字符串String 不仅要读取常规的选项组,还要读取带有常规名称并附有
str后缀的组。例如,mysqlcheck 通常读取[client]和[mysqlcheck]组。如果该选项以--defaults-group-suffix=_other提供,mysqlcheck 还会读取[client_other]和[mysqlcheck_other]组。Read not only the usual option groups, but also groups with the usual names and a suffix ofstr. For example, mysqlcheck normally reads the[client]and[mysqlcheck]groups. If this option is given as--defaults-group-suffix=_other, mysqlcheck also reads the[client_other]and[mysqlcheck_other]groups.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--extended,-e命令行格式Command-Line Format --extended如果您使用此选项来检查表,它可以确保它们 100% 一致,但需要很长时间。If you are using this option to check tables, it ensures that they are 100% consistent but takes a long time.
如果您使用此选项来修复表,它会运行扩展修复,这不仅可能需要很长时间执行,而且还可能产生大量垃圾行!If you are using this option to repair tables, it runs an extended repair that may not only take a long time to execute, but may produce a lot of garbage rows also!
--default-auth=plugin--default-auth=plugin命令行格式Command-Line Format --default-auth=plugin--default-auth=plugin类型Type 字符串String 关于使用哪种客户端身份验证插件的提示。请参见 第 8.2.17 节,“可插拔身份验证”。A hint about which client-side authentication plugin to use. See Section 8.2.17, “Pluggable Authentication”.
命令行格式Command-Line Format --enable-cleartext-plugin类型Type 布尔Boolean 默认值Default Value FALSE启用
mysql_clear_password明文身份验证插件。(参见 第 8.4.1.4 节,“客户端明文可插拔身份验证”。)Enable themysql_clear_passwordcleartext authentication plugin. (See Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”.)--fast,-F命令行格式Command-Line Format --fast只检查未正确关闭的表格。Check only tables that have not been closed properly.
--force,-f命令行格式Command-Line Format --force即使发生 SQL 错误也继续。Continue even if an SQL error occurs.
命令行格式Command-Line Format --get-server-public-key--get-server-public-key类型Type 布尔Boolean 向服务器请求用于基于 RSA 密钥对的密码交换所需的公钥。此选项适用于使用
caching_sha2_password身份验证插件进行身份验证的客户端。对于该插件,服务器不会发送公钥,除非被请求。对于未使用该插件进行身份验证的账户,此选项将被忽略。当未使用基于 RSA 的密码交换时(例如客户端使用安全连接连接服务器时),此选项也将被忽略。Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with thecaching_sha2_passwordauthentication plugin. For that plugin, the server does not send the public key unless requested. This option is ignored for accounts that do not authenticate with that plugin. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.如果
--server-public-key-path=给出并指定有效的公钥文件,它优先于file_name--get-server-public-key.If--server-public-key-path=is given and specifies a valid public key file, it takes precedence overfile_name--get-server-public-key.有关
caching_sha2_password插件的信息,请参见 第 8.4.1.2 节,“缓存 SHA-2 可插拔认证”。For information about thecaching_sha2_passwordplugin, see Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.--host=,host_name-h host_name--host=,host_name-hhost_name命令行格式Command-Line Format --host=host_name--host=host_name类型Type 字符串String 默认值Default Value localhostlocalhost连接到给定主机上的 MySQL 服务器。Connect to the MySQL server on the given host.
--login-path=name--login-path=name命令行格式Command-Line Format --login-path=name--login-path=name类型Type 字符串String 从名为登录路径的
.mylogin.cnf登录路径文件中读取选项。“登录路径” 是一个选项组,包含指定要连接哪个 MySQL 服务器以及以哪个帐户进行身份验证的选项。要创建或修改登录路径文件,请使用 mysql_config_editor 工具。参见 第 6.6.7 节,“mysql_config_editor — MySQL 配置工具”。Read options from the named login path in the.mylogin.cnflogin path file. A “login path” is an option group containing options that specify which MySQL server to connect to and which account to authenticate as. To create or modify a login path file, use the mysql_config_editor utility. See Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
命令行格式Command-Line Format --no-login-paths跳过从登录路径文件读取选项。Skips reading options from the login path file.
相关信息请参见
--login-path。See--login-pathfor related information.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--medium-check,-m命令行格式Command-Line Format --medium-check执行比
--extended操作更快的检查。这只会发现 99.99%的错误,在大多数情况下已经足够。Do a check that is faster than an--extendedoperation. This finds only 99.99% of all errors, which should be good enough in most cases.命令行格式Command-Line Format --no-defaults--no-defaults不读取任何选项文件。如果程序启动因从选项文件读取未知选项而失败,可以使用
--no-defaults来防止读取这些选项。Do not read any option files. If program startup fails due to reading unknown options from an option file,--no-defaultscan be used to prevent them from being read.例外情况是
.mylogin.cnf文件在所有情况下都会被读取(如果它存在)。这允许即使使用--no-defaults时,也能以比在命令行上更安全的方式指定密码。要创建.mylogin.cnf文件,请使用 mysql_config_editor 工具。参见 第 6.6.7 节,“mysql_config_editor — MySQL 配置工具”。The exception is that the.mylogin.cnffile is read in all cases, if it exists. This permits passwords to be specified in a safer way than on the command line even when--no-defaultsis used. To create.mylogin.cnf, use the mysql_config_editor utility. See Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”.有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--optimize,-o命令行格式Command-Line Format --optimize--optimize优化表格。Optimize the tables.
--password[=password],-p[password]--password[=,password]-p[password]命令行格式Command-Line Format --password[=password]--password[=password]类型Type 字符串String 用于连接服务器的 MySQL 帐户的密码。密码值是可选的。如果未给出,mysqlcheck 会提示输入一个。如果给出,
--password=或-p与其后面的密码之间必须没有空格。如果未指定密码选项,则默认不发送密码。The password of the MySQL account used for connecting to the server. The password value is optional. If not given, mysqlcheck prompts for one. If given, there must be no space between--password=or-pand the password following it. If no password option is specified, the default is to send no password.在命令行中指定密码应被视为不安全。为了避免在命令行中输入密码,请使用选项文件。请参阅 第 8.1.2.1 节,“终端用户密码安全指南”。Specifying a password on the command line should be considered insecure. To avoid giving the password on the command line, use an option file. See Section 8.1.2.1, “End-User Guidelines for Password Security”.
要明确指定没有密码并且mysqlcheck 不应提示输入密码,请使用
--skip-password选项。To explicitly specify that there is no password and that mysqlcheck should not prompt for one, use the--skip-passwordoption.用于连接服务器的 MySQL 帐户多因素认证因素 1 的密码。密码值是可选的。如果未提供,mysqlcheck 会提示输入密码。如果提供,必须在
--password1=和随后的密码之间 不能有空格。如果未指定密码选项,默认是不发送密码。The password for multifactor authentication factor 1 of the MySQL account used for connecting to the server. The password value is optional. If not given, mysqlcheck prompts for one. If given, there must be no space between--password1=and the password following it. If no password option is specified, the default is to send no password.在命令行中指定密码应被视为不安全。为了避免在命令行中输入密码,请使用选项文件。请参阅 第 8.1.2.1 节,“终端用户密码安全指南”。Specifying a password on the command line should be considered insecure. To avoid giving the password on the command line, use an option file. See Section 8.1.2.1, “End-User Guidelines for Password Security”.
要明确指定没有密码,并且 mysqlcheck 不应提示输入密码,请使用
--skip-password1选项。To explicitly specify that there is no password and that mysqlcheck should not prompt for one, use the--skip-password1option.--password1和--password是同义的,--skip-password1和--skip-password也是同义的。--password1and--passwordare synonymous, as are--skip-password1and--skip-password.用于连接服务器的 MySQL 账户的多因素认证第二因子的密码。此选项的语义与
--password1的语义类似;详情请参见该选项的描述。The password for multifactor authentication factor 2 of the MySQL account used for connecting to the server. The semantics of this option are similar to the semantics for--password1; see the description of that option for details.用于连接服务器的 MySQL 帐户的多因素认证第 3 因子的密码。此选项的语义类似于
--password1的语义;详细信息请参见该选项的描述。The password for multifactor authentication factor 3 of the MySQL account used for connecting to the server. The semantics of this option are similar to the semantics for--password1; see the description of that option for details.--pipe,-W命令行格式Command-Line Format --pipe类型Type 字符串String 在 Windows 上,通过命名管道连接到服务器。此选项仅在服务器启动时已启用
named_pipe系统变量以支持命名管道连接的情况下适用。此外,进行连接的用户必须是由named_pipe_full_access_group系统变量指定的 Windows 组的成员。On Windows, connect to the server using a named pipe. This option applies only if the server was started with thenamed_pipesystem variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by thenamed_pipe_full_access_groupsystem variable.--plugin-dir=dir_name--plugin-dir=dir_name命令行格式Command-Line Format --plugin-dir=dir_name--plugin-dir=dir_name类型Type 目录名称Directory name 查找插件的目录。如果使用
--default-auth选项指定身份验证插件,但 mysqlcheck 未找到它,则请指定此选项。参见 第 8.2.17 节,“可插拔身份验证”。The directory in which to look for plugins. Specify this option if the--default-authoption is used to specify an authentication plugin but mysqlcheck does not find it. See Section 8.2.17, “Pluggable Authentication”.--port=port_num,-P port_num--port=,port_num-Pport_num命令行格式Command-Line Format --port=port_num--port=port_num类型Type 数字Numeric 默认值Default Value 3306对于 TCP/IP 连接,要使用的端口号。For TCP/IP connections, the port number to use.
命令行格式Command-Line Format --print-defaults打印程序名称以及它从选项文件中获取的所有选项。Print the program name and all options that it gets from option files.
有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 6.2.2.3 节,“影响选项文件处理的命令行选项”。For additional information about this and other option-file options, see Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”.
--protocol={TCP|SOCKET|PIPE|MEMORY}命令行格式Command-Line Format --protocol=type--protocol=type类型Type 字符串String 默认值Default Value [see text][see text]有效值Valid Values TCPSOCKETSOCKETPIPEPIPEMEMORYMEMORY用于连接服务器的传输协议。当其他连接参数通常导致使用的协议不是您想要的协议时,这很有用。有关允许值的详细信息,请参阅第 6.2.7 节,“连接传输协议”。The transport protocol to use for connecting to the server. It is useful when the other connection parameters normally result in use of a protocol other than the one you want. For details on the permissible values, see Section 6.2.7, “Connection Transport Protocols”.
--quick,-q命令行格式Command-Line Format --quick--quick如果您使用此选项来检查表,它会阻止检查扫描行以查找错误链接。这是最快的检查方法。If you are using this option to check tables, it prevents the check from scanning the rows to check for incorrect links. This is the fastest check method.
如果您使用此选项来修复表,它只会尝试修复索引树。这是最快的修复方法。If you are using this option to repair tables, it tries to repair only the index tree. This is the fastest repair method.
--repair,-r命令行格式Command-Line Format --repair执行一种几乎可以修复任何东西的修复,除了那些不唯一的唯一键。Perform a repair that can fix almost anything except unique keys that are not unique.
--server-public-key-path=file_name--server-public-key-path=file_name命令行格式Command-Line Format --server-public-key-path=file_name--server-public-key-path=file_name类型Type 文件名File name 包含服务器所需的 RSA 密钥对密码交换的客户端副本公钥的 PEM 格式文件的路径名。此选项适用于使用
sha256_password(已弃用)或caching_sha2_password身份验证插件进行身份验证的客户端。对于不使用这些插件之一进行身份验证的帐户,将忽略此选项。如果未使用基于 RSA 的密码交换(例如客户端使用安全连接连接到服务器的情况),此选项也将被忽略。The path name to a file in PEM format containing a client-side copy of the public key required by the server for RSA key pair-based password exchange. This option applies to clients that authenticate with thesha256_password(deprecated) orcaching_sha2_passwordauthentication plugin. This option is ignored for accounts that do not authenticate with one of those plugins. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.如果
--server-public-key-path=给出并指定有效的公钥文件,它优先于file_name--get-server-public-key.If--server-public-key-path=is given and specifies a valid public key file, it takes precedence overfile_name--get-server-public-key.对于
sha256_password(已弃用),此选项仅在 MySQL 使用 OpenSSL 构建时才适用。Forsha256_password(deprecated), this option applies only if MySQL was built using OpenSSL.有关
sha256_password和caching_sha2_password插件的信息,请参见 第 8.4.1.3 节,“SHA-256 可插拔认证” 和 第 8.4.1.2 节,“缓存 SHA-2 可插拔认证”。For information about thesha256_passwordandcaching_sha2_passwordplugins, see Section 8.4.1.3, “SHA-256 Pluggable Authentication”, and Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.--shared-memory-base-name=name--shared-memory-base-name=name命令行格式Command-Line Format --shared-memory-base-name=name--shared-memory-base-name=name特定平台Platform Specific 窗口Windows 在 Windows 上,通过共享内存连接到本地服务器时使用的共享内存名称。默认值是
MYSQL。共享内存名称区分大小写。On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value isMYSQL. The shared-memory name is case-sensitive.此选项仅在服务器启用了
shared_memory系统变量以支持共享内存连接时适用。This option applies only if the server was started with theshared_memorysystem variable enabled to support shared-memory connections.--silent,-s命令行格式Command-Line Format --silent静音模式。仅打印错误信息。Silent mode. Print only error messages.
--skip-database=db_name--skip-database=db_name命令行格式Command-Line Format --skip-database=db_name--skip-database=db_name不要在mysqlcheck执行的操作中包含指定数据库(区分大小写)。Do not include the named database (case-sensitive) in the operations performed by mysqlcheck.
--socket=path,-S path--socket=,path-Spath命令行格式Command-Line Format --socket={file_name|pipe_name}--socket={file_name|pipe_name}类型Type 字符串String 用于连接
localhost时,使用的 Unix 套接字文件,或者在 Windows 上使用的命名管道的名称。For connections tolocalhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.在 Windows 上,此选项仅在服务器启用支持命名管道连接的
named_pipe系统变量启动时才适用。此外,进行连接的用户必须是由named_pipe_full_access_group系统变量指定的 Windows 组的成员。On Windows, this option applies only if the server was started with thenamed_pipesystem variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by thenamed_pipe_full_access_groupsystem variable.以
--ssl开头的选项指定是否使用加密连接到服务器,并指示在哪里可以找到 SSL 密钥和证书。请参阅 加密连接的命令选项。Options that begin with--sslspecify whether to connect to the server using encryption and indicate where to find SSL keys and certificates. See Command Options for Encrypted Connections.--ssl-fips-mode={OFF|ON|STRICT}--ssl-fips-mode={OFF|ON|STRICT}命令行格式Command-Line Format --ssl-fips-mode={OFF|ON|STRICT}--ssl-fips-mode={OFF|ON|STRICT}已弃用Deprecated 是Yes 类型Type 枚举Enumeration 默认值Default Value OFFOFF有效值Valid Values OFFOFFONONSTRICTSTRICT控制是否在客户端启用 FIPS 模式。
--ssl-fips-mode选项与其他--ssl-选项不同,因为它不用于建立加密连接,而是用于影响允许哪些加密操作。请参阅第 8.8 节“FIPS 支持”。Controls whether to enable FIPS mode on the client side. Thexxx--ssl-fips-modeoption differs from other--ssl-options in that it is not used to establish encrypted connections, but rather to affect which cryptographic operations to permit. See Section 8.8, “FIPS Support”.xxx允许使用这些
--ssl-fips-mode值:These--ssl-fips-modevalues are permitted:OFF:禁用 FIPS 模式。OFF: Disable FIPS mode.ON:启用 FIPS 模式。ON: Enable FIPS mode.STRICT:启用“严格” FIPS 模式。STRICT: Enable “strict” FIPS mode.
Note如果 OpenSSL FIPS 对象模块不可用,则
--ssl-fips-mode为OFF。在这种情况下,将--ssl-fips-mode设置为ON或STRICT会导致客户端在启动时生成警告并在非 FIPS 模式下运行。If the OpenSSL FIPS Object Module is not available, the only permitted value for--ssl-fips-modeisOFF. In this case, setting--ssl-fips-modetoONorSTRICTcauses the client to produce a warning at startup and to operate in non-FIPS mode.此选项已弃用。预计将在未来的 MySQL 版本中移除。This option is deprecated. Expect it to be removed in a future version of MySQL.
命令行格式Command-Line Format --tables覆盖
--databases或-B选项。该选项后面的所有名称参数都被视为表名称。Override the--databasesor-Boption. All name arguments following the option are regarded as table names.--tls-ciphersuites=ciphersuite_list命令行格式Command-Line Format --tls-ciphersuites=ciphersuite_list--tls-ciphersuites=ciphersuite_list类型Type 字符串String 用于 TLSv1.3 加密连接的允许密码套件。该值是一个或多个用冒号分隔的密码套件名称的列表。此选项可指定的密码套件取决于用于编译 MySQL 的 SSL 库。有关详细信息,请参见 第 8.3.2 节,“加密连接的 TLS 协议和密码”。The permissible ciphersuites for encrypted connections that use TLSv1.3. The value is a list of one or more colon-separated ciphersuite names. The ciphersuites that can be named for this option depend on the SSL library used to compile MySQL. For details, see Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
--tls-sni-servername=server_name--tls-sni-servername=server_name命令行格式Command-Line Format --tls-sni-servername=server_name--tls-sni-servername=server_name类型Type 字符串String 如果指定了名称,该名称将通过
mysql_options()的MYSQL_OPT_TLS_SNI_SERVERNAME选项传递给libmysqlclientC API 库。服务器名称不区分大小写。要显示客户端为当前会话指定的服务器名称(如果有),请检查Tls_sni_server_name状态变量。When specified, the name is passed to thelibmysqlclientC API library using theMYSQL_OPT_TLS_SNI_SERVERNAMEoption ofmysql_options(). The server name is not case-sensitive. To show which server name the client specified for the current session, if any, check theTls_sni_server_namestatus variable.服务器名称指示(SNI)是 TLS 协议的一个扩展(必须使用支持 TLS 扩展的 OpenSSL 编译此选项才能生效)。MySQL 对 SNI 的实现仅代表客户端。Server Name Indication (SNI) is an extension to the TLS protocol (OpenSSL must be compiled using TLS extensions for this option to function). The MySQL implementation of SNI represents the client-side only.
命令行格式Command-Line Format --tls-version=protocol_list--tls-version=protocol_list类型Type 字符串String 默认值Default Value TLSv1,TLSv1.1,TLSv1.2,TLSv1.3(OpenSSL 1.1.1 或更高版本)TLSv1,TLSv1.1,TLSv1.2,TLSv1.3(OpenSSL 1.1.1 or higher)TLSv1,TLSv1.1,TLSv1.2(否则)TLSv1,TLSv1.1,TLSv1.2(otherwise)用于加密连接的允许 TLS 协议。值是一个或多个以逗号分隔的协议名称列表。此选项可指定的协议取决于用于编译 MySQL 的 SSL 库。详情请参见 第 8.3.2 节,“加密连接 TLS 协议和密码”。The permissible TLS protocols for encrypted connections. The value is a list of one or more comma-separated protocol names. The protocols that can be named for this option depend on the SSL library used to compile MySQL. For details, see Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
命令行格式Command-Line Format --use-frm对于
MyISAM表的修复操作,从数据字典获取表结构,以便即使.MYI头损坏,也可以修复表。For repair operations onMyISAMtables, get the table structure from the data dictionary so that the table can be repaired even if the.MYIheader is corrupted.--user=user_name,-u user_name--user=,user_name-uuser_name命令行格式Command-Line Format --user=user_name,--user=user_name,类型Type 字符串String 用于连接服务器的 MySQL 帐户用户名。The user name of the MySQL account to use for connecting to the server.
--verbose,-v命令行格式Command-Line Format --verbose--verbose详细模式。打印有关程序运行的各个阶段的信息。Verbose mode. Print information about the various stages of program operation.
--version,-V命令行格式Command-Line Format --version显示版本信息并退出。Display version information and exit.
命令行格式Command-Line Format --write-binlog此选项默认启用,因此
ANALYZE TABLE,OPTIMIZE TABLE,以及REPAIR TABLE生成的语句由mysqlcheck会被写入二进制日志。使用--skip-write-binlog可使NO_WRITE_TO_BINLOG被添加到语句中,以便它们不会被记录。使用--skip-write-binlog当这些语句不应发送到副本或在使用二进制日志从备份恢复时运行时。This option is enabled by default, so thatANALYZE TABLE,OPTIMIZE TABLE, andREPAIR TABLEstatements generated by mysqlcheck are written to the binary log. Use--skip-write-binlogto causeNO_WRITE_TO_BINLOGto be added to the statements so that they are not logged. Use the--skip-write-binlogwhen these statements should not be sent to replicas or run when using the binary logs for recovery from backup.--zstd-compression-level=level--zstd-compression-level=level命令行格式Command-Line Format --zstd-compression-level=#类型Type 整数Integer 用于与服务器连接时使用
zstd压缩算法的压缩级别。允许的级别从 1 到 22,数值越大表示压缩级别越高。默认的zstd压缩级别为 3。对于不使用zstd压缩的连接,压缩级别设置没有效果。The compression level to use for connections to the server that use thezstdcompression algorithm. The permitted levels are from 1 to 22, with larger values indicating increasing levels of compression. The defaultzstdcompression level is 3. The compression level setting has no effect on connections that do not usezstdcompression.更多信息,请参阅 第 6.2.8 节,“连接压缩控制”。For more information, see Section 6.2.8, “Connection Compression Control”.