文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 87%

7.1.7 服务器命令选项7.1.7 Server Command Options

当您启动 mysqld 服务器时,您可以使用 第 6.2.2 节,“指定程序选项” 中描述的任何方法指定程序选项。最常见的方法是在选项文件或命令行中提供选项。然而,在大多数情况下,希望确保服务器每次运行时使用相同的选项。确保这一点的最佳方法是将它们列在选项文件中。参见 第 6.2.2.2 节,“使用选项文件”。该节还描述了选项文件的格式和语法。When you start the mysqld server, you can specify program options using any of the methods described in Section 6.2.2, “Specifying Program Options”. The most common methods are to provide options in an option file or on the command line. However, in most cases it is desirable to make sure that the server uses the same options each time it runs. The best way to ensure this is to list them in an option file. See Section 6.2.2.2, “Using Option Files”. That section also describes option file format and syntax.

mysqld 从 [mysqld] 和 [server] 组读取选项。mysqld_safe 从 [mysqld]、[server]、[mysqld_safe] 和 [safe_mysqld] 组读取选项。mysql.server 从 [mysqld] 和 [mysql.server] 组读取选项。mysqld reads options from the [mysqld] and [server] groups. mysqld_safe reads options from the [mysqld], [server], [mysqld_safe], and [safe_mysqld] groups. mysql.server reads options from the [mysqld] and [mysql.server] groups.

mysqld 接受许多命令选项。要查看简要摘要,请执行以下命令:mysqld accepts many command options. For a brief summary, execute this command:

mysqld --help

要查看完整列表,请使用此命令:To see the full list, use this command:

mysqld --verbose --help

列表中的一些项目实际上是可以在服务器启动时设置的系统变量。这些变量可以使用 SHOW VARIABLES 语句在运行时显示。前面 mysqld 命令显示的一些项目不会出现在 SHOW VARIABLES 输出中;这是因为它们只是选项,而不是系统变量。Some of the items in the list are actually system variables that can be set at server startup. These can be displayed at runtime using the SHOW VARIABLES statement. Some items displayed by the preceding mysqld command do not appear in SHOW VARIABLES output; this is because they are options only and not system variables.

以下列表显示了一些最常见的服务器选项。其他选项在其他部分中有所描述:The following list shows some of the most common server options. Additional options are described in other sections:

有些选项控制缓冲区或缓存的大小。对于给定的缓冲区,服务器可能需要分配内部数据结构。这些结构通常是从分配给缓冲区的总内存中分配的,并且所需空间的数量可能依赖于平台。这意味着当你为控制缓冲区大小的选项分配一个值时,实际上可用的空间可能与分配的值不同。在某些情况下,可用空间可能小于分配的值。服务器也可能将值向上调整。例如,如果你为一个最小值为 1024 的选项分配 0,服务器会将该值设置为 1024。Some options control the size of buffers or caches. For a given buffer, the server might need to allocate internal data structures. These structures typically are allocated from the total memory allocated to the buffer, and the amount of space required might be platform dependent. This means that when you assign a value to an option that controls a buffer size, the amount of space actually available might differ from the value assigned. In some cases, the amount might be less than the value assigned. It is also possible that the server adjusts a value upward. For example, if you assign a value of 0 to an option for which the minimal value is 1024, the server sets the value to 1024.

缓冲区大小、长度和堆栈大小的值以字节为单位,除非另有说明。Values for buffer sizes, lengths, and stack sizes are given in bytes unless otherwise specified.

某些选项需要文件名作为值。除非另有说明,如果值是相对路径名,则默认文件位置是数据目录。要明确指定位置,请使用绝对路径名。假设数据目录是 /var/mysql/data。如果文件值选项以相对路径名给出,则其位置在 /var/mysql/data 下。如果值是绝对路径名,则其位置如路径名所示。Some options take file name values. Unless otherwise specified, the default file location is the data directory if the value is a relative path name. To specify the location explicitly, use an absolute path name. Suppose that the data directory is /var/mysql/data. If a file-valued option is given as a relative path name, it is located under /var/mysql/data. If the value is an absolute path name, its location is as given by the path name.

您还可以在服务器启动时通过使用变量名作为选项来设置服务器系统变量的值。要为服务器系统变量分配值,请使用形式为--var_name=value的选项。例如,--sort_buffer_size=384M 将 sort_buffer_size 变量设置为 384MB。You can also set the values of server system variables at server startup by using variable names as options. To assign a value to a server system variable, use an option of the form --var_name=value. For example, --sort_buffer_size=384M sets the sort_buffer_size variable to a value of 384MB.

当你给变量赋值时,MySQL 可能会自动将该值修改为保持在给定范围内,或者如果只允许某些值,会将其调整为最接近的允许值。When you assign a value to a variable, MySQL might automatically correct the value to stay within a given range, or adjust the value to the closest permissible value if only certain values are permitted.

要限制系统变量在运行时使用 SET 语句可以设置的最大值,请在服务器启动时使用如下格式的选项指定此最大值:--maximum-var_name=value。To restrict the maximum value to which a system variable can be set at runtime with the SET statement, specify this maximum by using an option of the form --maximum-var_name=value at server startup.

您可以使用 SET 语句在运行时更改大多数系统变量的值。请参见 第 15.7.6.1 节,“SET 变量赋值语法”。You can change the values of most system variables at runtime with the SET statement. See Section 15.7.6.1, “SET Syntax for Variable Assignment”.

第 7.1.8 节,“服务器系统变量”,提供了所有变量的完整描述,以及在服务器启动和运行时设置它们的附加信息。有关更改系统变量的信息,请参阅 第 7.1.1 节,“配置服务器”。Section 7.1.8, “Server System Variables”, provides a full description for all variables, and additional information for setting them at server startup and runtime. For information on changing system variables, see Section 7.1.1, “Configuring the Server”.

  • --help, -?

    命令行格式Command-Line Format --help--help

    显示简短的帮助信息并退出。使用 --verbose 和 --help 选项可以查看完整信息。Display a short help message and exit. Use both the --verbose and --help options to see the full message.

  • --allow-suspicious-udfs

    命令行格式Command-Line Format --allow-suspicious-udfs[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此选项控制是否可以加载主函数仅具有 xxx 符号的可加载函数。默认情况下,此选项为关闭,只有具有至少一个辅助符号的可加载函数可以加载;这可以防止尝试从除包含合法函数之外的共享对象文件加载函数。请参阅 可加载函数安全预防措施。This option controls whether loadable functions that have only an xxx symbol for the main function can be loaded. By default, the option is off and only loadable functions that have at least one auxiliary symbol can be loaded; this prevents attempts at loading functions from shared object files other than those containing legitimate functions. See Loadable Function Security Precautions.

  • --ansi

    命令行格式Command-Line Format --ansi

    使用标准(ANSI)SQL 语法而不是 MySQL 语法。要对服务器 SQL 模式进行更精确的控制,请改用 --sql-mode 选项。详见 第 1.7 节,“MySQL 标准兼容性”,以及 第 7.1.11 节,“服务器 SQL 模式”。Use standard (ANSI) SQL syntax instead of MySQL syntax. For more precise control over the server SQL mode, use the --sql-mode option instead. See Section 1.7, “MySQL Standards Compliance”, and Section 7.1.11, “Server SQL Modes”.

  • --basedir=dir_name, -b dir_name --basedir=dir_name, -b dir_name

    命令行格式Command-Line Format --basedir=dir_name--basedir=dir_name
    系统变量System Variable basedir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name
    默认值Default Value parent of mysqld installation directoryparent of mysqld installation directory

    MySQL 安装目录的路径。此选项设置 basedir 系统变量。The path to the MySQL installation directory. This option sets the basedir system variable.

    服务器可执行文件在启动时会确定其自身的完整路径名,并使用其所在目录的父目录作为默认的basedir值。这反过来使服务器在搜索与服务器相关的信息时,如包含错误信息的share目录时,可以使用该basedir。The server executable determines its own full path name at startup and uses the parent of the directory in which it is located as the default basedir value. This in turn enables the server to use that basedir when searching for server-related information such as the share directory containing error messages.

  • --check-table-functions=value --check-table-functions=value

    命令行格式Command-Line Format --check-table-functions=value--check-table-functions=value
    类型Type 枚举Enumeration
    默认值Default Value ABORTABORT
    有效值Valid Values

    WARNWARN

    ABORTABORT

    在执行服务器升级时,我们会扫描数据字典中在表约束和其他表达式中使用的函数,包括DEFAULT表达式、分区表达式和虚拟列。函数行为的变化可能会导致在新版本服务器中出现错误,而在之前版本中没有此类错误,这种情况下表无法打开。此选项提供了一种处理此类问题的方式,根据这里显示的两个值之一进行选择:When performing an upgade of the server, we scan the data dictionary for functions used in table constraints and other expressions, including DEFAULT expressions, partitioning expressions, and virtual columns. It is possible that a change in the behavior of the function causes it to raise an error in the new version of the server, where no such error occurred before in which case the table cannot be opened. This option provides a choice in how to handle such problems, according to which of the two values shown here is used:

    • WARN:记录每个无法打开的表的警告。WARN: Log a warning for each table that cannot be opened.

    • ABORT:同时记录警告;此外,升级将被停止。这是默认设置。对于足够高的--log-error-verbosity值,它还会记录一个注释,其中包含简化的表定义,仅列出可能包含 SQL 函数的表达式。ABORT: Also logs a warning; in addition, the upgrade is stopped. This is the default. For a sufficiently high value of --log-error-verbosity, it also logs a note with a streamlined table definition listing only those expressions that potentially contain SQL functions.

    默认行为是中止升级,以便用户可以使用旧版本的服务器修复问题,然后再升级到新版本。使用 WARN 可以在交互模式下继续升级,同时报告任何问题。The default behaviour is to abort the upgrade, so that the user can fix the issue using the older version of the server, before upgrading to the newer one. Use WARN to continue the upgrade in interactive mode while reporting any issues.

    --check-table-functions 选项首次引入于 MySQL 8.4.5。The --check-table-functions option was introduced in MySQL 8.4.5.

  • --chroot=dir_name, -r dir_name

    命令行格式Command-Line Format --chroot=dir_name
    类型Type 目录名称Directory name

    在启动时使用 chroot() 系统调用将 mysqld 服务器置于封闭环境中。这是一项推荐的安全措施。使用此选项会在一定程度上限制 LOAD DATA 和 SELECT ... INTO OUTFILE 的使用。Put the mysqld server in a closed environment during startup by using the chroot() system call. This is a recommended security measure. Use of this option somewhat limits LOAD DATA and SELECT ... INTO OUTFILE.

  • --console

    命令行格式Command-Line Format --console
    特定平台Platform Specific 窗口Windows

    (仅限 Windows。)使默认错误日志输出到控制台。这会影响基于默认目标设置自身输出目标的日志接收器。参见 第 7.4.2 节,“错误日志”。mysqld 如果使用此选项,不会关闭控制台窗口。(Windows only.) Cause the default error log destination to be the console. This affects log sinks that base their own output destination on the default destination. See Section 7.4.2, “The Error Log”. mysqld does not close the console window if this option is used.

    --console 优先于 --log-error,如果两者同时给出。--console takes precedence over --log-error if both are given.

  • --core-file

    命令行格式Command-Line Format --core-file

    当使用此选项时,如果mysqld 崩溃,将生成核心文件;无需(也不接受)任何参数。核心文件的名称和位置取决于操作系统。在 Linux 上,名为 core.pid 的核心文件将写入进程的当前工作目录,对于 mysqld 来说,即数据目录。pid 代表服务器进程的进程 ID。在 macOS 上,名为 core.pid 的核心文件将写入 /cores 目录。在 Solaris 上,使用 coreadm 命令来指定核心文件的写入位置和命名方式。When this option is used, write a core file if mysqld dies; no arguments are needed (or accepted). The name and location of the core file is system dependent. On Linux, a core file named core.pid is written to the current working directory of the process, which for mysqld is the data directory. pid represents the process ID of the server process. On macOS, a core file named core.pid is written to the /cores directory. On Solaris, use the coreadm command to specify where to write the core file and how to name it.

    对于某些系统,要生成核心文件,你还必须为 --core-file-size 选项指定 mysqld_safe。参见 第 6.3.2 节,“mysqld_safe — MySQL 服务器启动脚本”。在某些系统上,例如 Solaris,如果你同时使用 --user 选项,将不会生成核心文件。可能还会有其他限制或约束。例如,在启动服务器之前可能需要执行 ulimit -c unlimited。请参考你的系统文档。For some systems, to get a core file you must also specify the --core-file-size option to mysqld_safe. See Section 6.3.2, “mysqld_safe — MySQL Server Startup Script”. On some systems, such as Solaris, you do not get a core file if you are also using the --user option. There might be additional restrictions or limitations. For example, it might be necessary to execute ulimit -c unlimited before starting the server. Consult your system documentation.

    innodb_buffer_pool_in_core_file 变量可用于在支持的操作系统上减少核心文件的大小。更多信息,请参阅 第 17.8.3.7 节,“从核心文件中排除或包含缓冲池页”。The innodb_buffer_pool_in_core_file variable can be used to reduce the size of core files on operating systems that support it. For more information, see Section 17.8.3.7, “Excluding or Including Buffer Pool Pages from Core Files”.

  • --daemonize, -D

    命令行格式Command-Line Format --daemonize[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此选项使服务器以传统的分叉守护进程方式运行,从而允许其在使用 systemd 进行进程控制的操作系统上工作。有关更多信息,请参见 第 2.5.9 节,“使用 systemd 管理 MySQL 服务器”。This option causes the server to run as a traditional, forking daemon, permitting it to work with operating systems that use systemd for process control. For more information, see Section 2.5.9, “Managing MySQL Server with systemd”.

    --daemonize 与 --initialize 和 --initialize-insecure 互斥。--daemonize is mutually exclusive with --initialize and --initialize-insecure.

    如果使用 --daemonize 选项启动服务器并且没有连接到 tty 设备,在没有明确指定日志选项的情况下,将使用默认的错误日志选项 --log-error="",以将错误输出写入默认日志文件。If the server is started using the --daemonize option and is not connected to a tty device, a default error logging option of --log-error="" is used in the absence of an explicit logging option, to direct error output to the default log file.

    -D 是 --daemonize 的同义词。-D is a synonym for --daemonize.

  • --datadir=dir_name, -h dir_name --datadir=dir_name, -h dir_name

    命令行格式Command-Line Format --datadir=dir_name--datadir=dir_name
    系统变量System Variable datadir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name

    MySQL 服务器数据目录的路径。此选项设置 datadir 系统变量。请参阅该变量的描述。The path to the MySQL server data directory. This option sets the datadir system variable. See the description of that variable.

  • --debug[=debug_options], -# [debug_options]

    命令行格式Command-Line Format --debug[=debug_options]--debug[=debug_options]
    系统变量System Variable debugdebug
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值(Unix)Default Value (Unix) d:t:i:o,/tmp/mysqld.trace
    默认值(Windows)Default Value (Windows) d:t:i:O,\mysqld.trace

    如果 MySQL 配置了 -DWITH_DEBUG=1 CMake 选项,你可以使用此选项获取 mysqld 正在执行操作的跟踪文件。典型的 debug_options 字符串是 d:t:o,file_name。默认值在 Unix 上是 d:t:i:o,/tmp/mysqld.trace,在 Windows 上是 d:t:i:O,\mysqld.trace。If MySQL is configured with the -DWITH_DEBUG=1 CMake option, you can use this option to get a trace file of what mysqld is doing. A typical debug_options string is d:t:o,file_name. The default is d:t:i:o,/tmp/mysqld.trace on Unix and d:t:i:O,\mysqld.trace on Windows.

    使用 -DWITH_DEBUG=1 配置带有调试支持的 MySQL,可在启动服务器时使用 --debug="d,parser_debug" 选项。这会导致用于处理 SQL 语句的 Bison 解析器将解析器跟踪信息输出到服务器的标准错误输出。通常,这些输出会写入错误日志。Using -DWITH_DEBUG=1 to configure MySQL with debugging support enables you to use the --debug="d,parser_debug" option when you start the server. This causes the Bison parser that is used to process SQL statements to dump a parser trace to the server's standard error output. Typically, this output is written to the error log.

    此选项可以多次使用。以 + 或 - 开头的值将被添加到或者从前一个值中减去。例如,--debug=T --debug=+P 将值设置为 P:T。This option may be given multiple times. Values that begin with + or - are added to or subtracted from the previous value. For example, --debug=T --debug=+P sets the value to P:T.

    更多信息,请参阅 第 7.9.4 节,“DBUG 包”。For more information, see Section 7.9.4, “The DBUG Package”.

  • --debug-sync-timeout[=N]

    命令行格式Command-Line Format --debug-sync-timeout[=#]
    类型Type 整数Integer

    控制是否启用用于测试和调试的 Debug Sync 功能。使用 Debug Sync 需要 MySQL 使用 -DWITH_DEBUG=ON CMake 选项进行配置(参见 第 2.8.7 节,“MySQL 源代码配置选项”);否则,此选项不可用。该选项的值是以秒为单位的超时时间。默认值为 0,表示禁用 Debug Sync。要启用它,请指定大于 0 的值;此值也将成为各个同步点的默认超时时间。如果该选项未指定值,则超时时间设置为 300 秒。Controls whether the Debug Sync facility for testing and debugging is enabled. Use of Debug Sync requires that MySQL be configured with the -DWITH_DEBUG=ON CMake option (see Section 2.8.7, “MySQL Source-Configuration Options”); otherwise, this option is not available. The option value is a timeout in seconds. The default value is 0, which disables Debug Sync. To enable it, specify a value greater than 0; this value also becomes the default timeout for individual synchronization points. If the option is given without a value, the timeout is set to 300 seconds.

    有关调试同步工具以及如何使用同步点的说明,请参阅 MySQL 内部结构:测试同步。For a description of the Debug Sync facility and how to use synchronization points, see MySQL Internals: Test Synchronization.

  • --default-time-zone=timezone --default-time-zone=timezone

    命令行格式Command-Line Format --default-time-zone=name
    类型Type 字符串String

    设置默认的服务器时区。此选项设置全局time_zone系统变量。如果未提供此选项,则默认时区与系统时区相同(由system_time_zone系统变量的值给出)。Set the default server time zone. This option sets the global time_zone system variable. If this option is not given, the default time zone is the same as the system time zone (given by the value of the system_time_zone system variable.

    system_time_zone 变量不同于 time_zone。虽然它们可能具有相同的值,但后者变量用于初始化每个连接客户端的时区。请参见 第 7.1.15 节,“MySQL 服务器时区支持”。The system_time_zone variable differs from time_zone. Although they might have the same value, the latter variable is used to initialize the time zone for each client that connects. See Section 7.1.15, “MySQL Server Time Zone Support”.

  • --defaults-extra-file=file_name --defaults-extra-file=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. If file_name is not an absolute path name, it is interpreted relative to the current directory. This must be the first option on the command line if it is used.

    有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 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

    只读取指定的选项文件。如果文件不存在或无法访问,则会发生错误。如果file_name不是绝对路径名,它将相对于当前目录进行解释。Read only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If file_name is not an absolute path name, it is interpreted relative to the current directory.

    例外:即使使用 --defaults-file,mysqld 仍会读取 mysqld-auto.cnf。Exception: Even with --defaults-file, mysqld reads mysqld-auto.cnf.

    Note

    如果使用该选项,它必须是命令行中的第一个选项,除非服务器是通过 --defaults-file 和 --install(或 --install-manual)选项启动的,那么 --install(或 --install-manual)必须是第一个选项。This must be the first option on the command line if it is used, except that if the server is started with the --defaults-file and --install (or --install-manual) options, --install (or --install-manual) must be first.

    有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 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

    不仅读取常规的选项组,还读取具有常规名称且后缀为str的组。例如,mysqld通常读取[mysqld]组。如果此选项以--defaults-group-suffix=_other形式给出,mysqld也会读取[mysqld_other]组。Read not only the usual option groups, but also groups with the usual names and a suffix of str. For example, mysqld normally reads the [mysqld] group. If this option is given as --defaults-group-suffix=_other, mysqld also reads the [mysqld_other] group.

    有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 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”.

  • --early-plugin-load=plugin_list

    命令行格式Command-Line Format --early-plugin-load=plugin_list
    类型Type 字符串String
    默认值Default Value empty stringempty string

    此选项告诉服务器在加载必需的内置插件和存储引擎初始化之前加载哪些插件。早期加载仅支持使用 PLUGIN_OPT_ALLOW_EARLY 编译的插件。如果给定多个 --early-plugin-load 选项,则仅最后一个生效。This option tells the server which plugins to load before loading mandatory built-in plugins and before storage engine initialization. Early loading is supported only for plugins compiled with PLUGIN_OPT_ALLOW_EARLY. If multiple --early-plugin-load options are given, only the last one applies.

    该选项值是一个由分号分隔的plugin_library和name=plugin_library值组成的列表。每个plugin_library都是包含插件代码的库文件的名称,每个name是要加载的插件的名称。如果插件库的名称没有前置插件名称,服务器将加载库中的所有插件。如果有前置插件名称,服务器只加载库中命名的插件。服务器在由plugin_dir系统变量指定的目录中查找插件库文件。The option value is a semicolon-separated list of plugin_library and name=plugin_library values. Each plugin_library is the name of a library file that contains plugin code, and each name is the name of a plugin to load. If a plugin library is named without any preceding plugin name, the server loads all plugins in the library. With a preceding plugin name, the server loads only the named plugin from the library. The server looks for plugin library files in the directory named by the plugin_dir system variable.

    例如,如果名为myplug1和myplug2的插件包含在插件库文件myplug1.so和myplug2.so中,请使用此选项执行早期插件加载:For example, if plugins named myplug1 and myplug2 are contained in the plugin library files myplug1.so and myplug2.so, use this option to perform an early plugin load:

    mysqld --early-plugin-load="myplug1=myplug1.so;myplug2=myplug2.so"
    

    参数值需要用引号括起来,否则某些命令解释器会将分号(;)解释为特殊字符。(例如,Unix shell 将其视为命令终止符。)Quotes surround the argument value because otherwise some command interpreters interpret semicolon (;) as a special character. (For example, Unix shells treat it as a command terminator.)

    每个命名插件仅在单次调用mysqld时提前加载。重启后,除非再次使用--early-plugin-load,否则插件不会提前加载。Each named plugin is loaded early for a single invocation of mysqld only. After a restart, the plugin is not loaded early unless --early-plugin-load is used again.

    如果服务器使用--initialize或--initialize-insecure启动,则由--early-plugin-load指定的插件不会被加载。If the server is started using --initialize or --initialize-insecure, plugins specified by --early-plugin-load are not loaded.

    如果服务器使用--help运行,则由--early-plugin-load指定的插件会被加载但不会初始化。此行为确保插件选项显示在帮助信息中。If the server is run with --help, plugins specified by --early-plugin-load are loaded but not initialized. This behavior ensures that plugin options are displayed in the help message.

    InnoDB 表空间加密依赖于 MySQL Keyring 来管理加密密钥,并且要使用的 keyring 插件必须在存储引擎初始化之前加载,以便能够进行 InnoDB 加密表的恢复。例如,希望在启动时加载 keyring_okv 插件的管理员应使用 --early-plugin-load 并指定适当的选项值(例如在 Unix 和类 Unix 系统上为 keyring_okv.so,在 Windows 上为 keyring_okv.dll)。InnoDB tablespace encryption relies on the MySQL Keyring for encryption key management, and the keyring plugin to be used must be loaded prior to storage engine initialization to facilitate InnoDB recovery for encrypted tables. For example, administrators who want the keyring_okv plugin loaded at startup should use --early-plugin-load with the appropriate option value (such as keyring_okv.so on Unix and Unix-like systems or keyring_okv.dll on Windows).

    有关 InnoDB 表空间加密的信息,请参阅 第 17.13 节,“InnoDB 静态数据加密”。有关插件加载的一般信息,请参阅 第 7.6.1 节,“安装和卸载插件”。For information about InnoDB tablespace encryption, see Section 17.13, “InnoDB Data-at-Rest Encryption”. For general information about plugin loading, see Section 7.6.1, “Installing and Uninstalling Plugins”.

    Note

    对于 MySQL Keyring,此选项仅在使用 keyring 插件管理密钥存储时使用。如果密钥存储管理使用的是 keyring 组件而不是插件,请使用清单文件指定组件加载;参见 第 8.4.4.2 节,“Keyring 组件安装”。For MySQL Keyring, this option is used only when the keystore is managed with a keyring plugin. If keystore management uses a keyring component rather than a plugin, specify component loading using a manifest file; see Section 8.4.4.2, “Keyring Component Installation”.

  • --exit-info[=flags], -T [flags]

    命令行格式Command-Line Format --exit-info[=flags]
    类型Type 整数Integer

    这是一个不同标志的位掩码,可用于调试mysqld服务器。除非你确切知道它的作用,否则不要使用此选项!在 Windows 上,This is a bitmask of different flags that you can use for debugging the mysqld server. Do not use this option unless you know exactly what it does!

  • --external-locking

    命令行格式Command-Line Format --external-locking[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    启用外部锁定(系统锁定),默认情况下是禁用的。如果在 lockd 无法完全工作的系统上使用此选项(例如 Linux),mysqld 很容易发生死锁。Enable external locking (system locking), which is disabled by default. If you use this option on a system on which lockd does not fully work (such as Linux), it is easy for mysqld to deadlock.

    要显式禁用外部锁定,请使用 --skip-external-locking。To disable external locking explicitly, use --skip-external-locking.

    外部锁定仅影响 MyISAM 表的访问。有关更多信息,包括可用和不可用的条件,请参见 第 10.11.5 节,“外部锁定”。External locking affects only MyISAM table access. For more information, including conditions under which it can and cannot be used, see Section 10.11.5, “External Locking”.

  • --flush

    命令行格式Command-Line Format --flush[={OFF|ON}]
    系统变量System Variable flush
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    在每条 SQL 语句之后将所有更改刷新(同步)到磁盘。通常,MySQL 仅在每条 SQL 语句之后将所有更改写入磁盘,并让操作系统处理同步到磁盘。参见 B.3.3.3 节,“如果 MySQL 不断崩溃该怎么办”。Flush (synchronize) all changes to disk after each SQL statement. Normally, MySQL does a write of all changes to disk only after each SQL statement and lets the operating system handle the synchronizing to disk. See Section B.3.3.3, “What to Do If MySQL Keeps Crashing”.

    Note

    如果指定了 --flush,则 flush_time 的值无关紧要,对 flush_time 的更改也不会影响刷新行为。If --flush is specified, the value of flush_time does not matter and changes to flush_time have no effect on flush behavior.

  • --gdb

    命令行格式Command-Line Format --gdb[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    为 SIGINT 安装中断处理程序(需要用 ^C 停止 mysqld 以设置断点),并禁用堆栈跟踪和核心文件处理。参见 第 7.9.1.4 节,“在 gdb 下调试 mysqld”。Install an interrupt handler for SIGINT (needed to stop mysqld with ^C to set breakpoints) and disable stack tracing and core file handling. See Section 7.9.1.4, “Debugging mysqld under gdb”.

    在 Windows 上,此选项还会抑制用于实现 RESTART 语句的分叉操作:分叉使一个进程充当另一个进程的监视器,而另一个进程充当服务器。然而,分叉会使确定要附加进行调试的服务器进程变得更加困难,因此使用 --gdb 启动服务器会抑制分叉。对于使用此选项启动的服务器,RESTART 只是退出,而不会重新启动。On Windows, this option also suppresses the forking that is used to implement the RESTART statement: Forking enables one process to act as a monitor to the other, which acts as the server. However, forking makes determining the server process to attach to for debugging more difficult, so starting the server with --gdb suppresses forking. For a server started with this option, RESTART simply exits and does not restart.

    在非调试设置中,可以使用 --no-monitor 来抑制监视器进程的分叉。In non-debug settings, --no-monitor may be used to suppress forking the monitor process.

  • --initialize, -I

    命令行格式Command-Line Format --initialize[={OFF|ON}]--initialize[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此选项用于通过创建数据目录并填充 mysql 系统模式中的表来初始化 MySQL 安装。如需更多信息,请参见 第 2.9.1 节,“初始化数据目录”。This option is used to initialize a MySQL installation by creating the data directory and populating the tables in the mysql system schema. For more information, see Section 2.9.1, “Initializing the Data Directory”.

    此选项会限制 MySQL 服务器的某些启动选项的效果,或与之不兼容。此类最常见的问题在此列出:This option limits the effects of, or is not compatible with, a number of other startup options for the MySQL server. Some of the most common issues of this sort are noted here:

    • 我们强烈建议,在使用 --initialize 初始化数据目录时,除了 --datadir 之外,不要指定其他附加选项,其他用于设置目录位置的选项如 --basedir,以及在必要时可能使用的 --user。运行中 MySQL 服务器的选项可以在初始化完成并且 mysqld 已关闭后启动时指定。当使用 --initialize-insecure 代替 --initialize 时,也适用此规则。We strongly recommend, when initializing the data directory with --initialize, that you specify no additional options other than --datadir, other options used for setting directory locations such as --basedir, and possibly --user, if required. Options for the running MySQL server can be specified when starting it once initialization has been completed and mysqld has shut down. This also applies when using --initialize-insecure instead of --initialize.

    • 当服务器使用 --initialize 启动时,一些功能不可用,这限制了任何由 init_file 系统变量指定的文件中允许的语句。有关详细信息,请参阅该变量的描述。此外,disabled_storage_engines 系统变量不起作用。When the server is started with --initialize, some functionality is unavailable that limits the statements permitted in any file named by the init_file system variable. For more information, see the description of that variable. In addition, the disabled_storage_engines system variable has no effect.

    • 当与 --initialize 一起使用时,--ndbcluster 选项将被忽略。The --ndbcluster option is ignored when used together with --initialize.

    • --initialize 与 --bootstrap 和 --daemonize 互斥。--initialize is mutually exclusive with --bootstrap and --daemonize.

    前面列表中的项目在使用 --initialize-insecure 选项初始化服务器时也适用。The items in the preceding list also apply when initializing the server using the --initialize-insecure option.

  • --initialize-insecure

    命令行格式Command-Line Format --initialize-insecure[={OFF|ON}]--initialize-insecure[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此选项用于通过创建数据目录并填充 mysql 系统模式中的表来初始化 MySQL 安装。此选项意味着 --initialize,并且适用相同的限制和约束;有关更多信息,请参阅该选项的描述,以及 第 2.9.1 节,“初始化数据目录”。This option is used to initialize a MySQL installation by creating the data directory and populating the tables in the mysql system schema. This option implies --initialize, and the same restrictions and limitations apply; for more information, see the description of that option, and Section 2.9.1, “Initializing the Data Directory”.

    Warning

    此选项会创建一个 MySQL root 用户且密码为空,这是不安全的。因此,在生产环境中使用此选项前,请务必手动设置密码。有关如何操作,请参见 初始化后 root 密码分配。This option creates a MySQL root user with an empty password, which is insecure. For this reason, do not use it in production without setting this password manually. See Post-Initialization root Password Assignment, for information about how to do this.

  • --innodb-xxx

    为 InnoDB 存储引擎设置选项。InnoDB 的选项列在 第 17.14 节,“InnoDB 启动选项和系统变量” 中。Set an option for the InnoDB storage engine. The InnoDB options are listed in Section 17.14, “InnoDB Startup Options and System Variables”.

  • --install [service_name] --install [service_name]

    命令行格式Command-Line Format --install [service_name]--install [service_name]
    特定平台Platform Specific 窗口Windows

    (仅限 Windows)将服务器安装为 Windows 服务,使其在 Windows 启动时自动启动。如果未提供 service_name 值,默认服务名称为 MySQL。有关更多信息,请参见 第 2.3.3.8 节,“作为 Windows 服务启动 MySQL”。(Windows only) Install the server as a Windows service that starts automatically during Windows startup. The default service name is MySQL if no service_name value is given. For more information, see Section 2.3.3.8, “Starting MySQL as a Windows Service”.

    Note

    如果服务器使用 --defaults-file 和 --install 选项启动,--install 必须放在第一个。If the server is started with the --defaults-file and --install options, --install must be first.

  • --install-manual [service_name] --install-manual [service_name]

    命令行格式Command-Line Format --install-manual [service_name]--install-manual [service_name]
    特定平台Platform Specific 窗口Windows

    (仅限 Windows)将服务器安装为必须手动启动的 Windows 服务。它不会在 Windows 启动时自动启动。如果未提供 service_name 值,默认的服务名为 MySQL。更多信息,请参阅 第 2.3.3.8 节,“以 Windows 服务启动 MySQL”。(Windows only) Install the server as a Windows service that must be started manually. It does not start automatically during Windows startup. The default service name is MySQL if no service_name value is given. For more information, see Section 2.3.3.8, “Starting MySQL as a Windows Service”.

    Note

    如果服务器使用 --defaults-file 和 --install-manual 选项启动,则 --install-manual 必须放在前面。If the server is started with the --defaults-file and --install-manual options, --install-manual must be first.

  • --large-pages

    命令行格式Command-Line Format --large-pages[={OFF|ON}]
    系统变量System Variable large_pages
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    特定平台Platform Specific Linux
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    一些硬件/操作系统架构支持比默认值(通常为 4KB)更大的内存页。此支持的实际实现取决于底层硬件和操作系统。由于减少了转换后备缓冲(TLB)未命中,执行大量内存访问的应用程序通过使用大页可能获得性能提升。Some hardware/operating system architectures support memory pages greater than the default (usually 4KB). The actual implementation of this support depends on the underlying hardware and operating system. Applications that perform a lot of memory accesses may obtain performance improvements by using large pages due to reduced Translation Lookaside Buffer (TLB) misses.

    MySQL 支持 Linux 对大页的实现(在 Linux 中称为 HugeTLB)。请参见 第 10.12.3.3 节,“启用大页支持”。有关 Solaris 对大页的支持,请参见 --super-large-pages 选项的说明。MySQL supports the Linux implementation of large page support (which is called HugeTLB in Linux). See Section 10.12.3.3, “Enabling Large Page Support”. For Solaris support of large pages, see the description of the --super-large-pages option.

    --large-pages 默认情况下是禁用的。--large-pages is disabled by default.

  • --lc-messages=locale_name

    命令行格式Command-Line Format --lc-messages=name
    系统变量System Variable lc_messages
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value en_US

    用于错误消息的区域设置。默认值为 en_US。服务器将参数转换为语言名称,并将其与 --lc-messages-dir 的值结合,以生成错误消息文件的位置。参见 第 12.12 节,“设置错误消息语言”。The locale to use for error messages. The default is en_US. The server converts the argument to a language name and combines it with the value of --lc-messages-dir to produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.

  • --lc-messages-dir=dir_name

    命令行格式Command-Line Format --lc-messages-dir=dir_name
    系统变量System Variable lc_messages_dir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name

    存放错误消息的目录。服务器将该值与--lc-messages的值一起使用,以生成错误消息文件的位置。参见第 12.12 节,“设置错误消息语言”。The directory where error messages are located. The server uses the value together with the value of --lc-messages to produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.

  • --local-service

    命令行格式Command-Line Format --local-service

    (仅限 Windows)在服务名称之后使用 --local-service 选项会使服务器以拥有有限系统权限的 LocalService Windows 账户运行。如果在服务名称之后同时提供 --defaults-file 和 --local-service,它们的顺序可以任意。参见 第 2.3.3.8 节,“将 MySQL 作为 Windows 服务启动”。(Windows only) A --local-service option following the service name causes the server to run using the LocalService Windows account that has limited system privileges. If both --defaults-file and --local-service are given following the service name, they can be in any order. See Section 2.3.3.8, “Starting MySQL as a Windows Service”.

  • --log-error[=file_name] --log-error[=file_name]

    命令行格式Command-Line Format --log-error[=file_name]--log-error[=file_name]
    系统变量System Variable log_error
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name

    将默认错误日志的目标设置为指定的文件。这会影响那些基于默认目标确定自身输出目标的日志接收器。请参阅 第 7.4.2 节,“错误日志”。Set the default error log destination to the named file. This affects log sinks that base their own output destination on the default destination. See Section 7.4.2, “The Error Log”.

    如果选项未指定文件,则在 Unix 和类 Unix 系统上,默认错误日志目标是数据目录中的名为 host_name.err 的文件。在 Windows 上,默认目标相同,除非指定了 --pid-file 选项。在这种情况下,文件名为 PID 文件的基本名,后缀为 .err,位于数据目录中。If the option names no file, the default error log destination on Unix and Unix-like systems is a file named host_name.err in the data directory. The default destination on Windows is the same, unless the --pid-file option is specified. In that case, the file name is the PID file base name with a suffix of .err in the data directory.

    如果选项指定了一个文件,默认的目标就是该文件(如果文件名没有后缀,则会添加一个.err后缀),文件位于数据目录下,除非提供了绝对路径来指定不同的位置。If the option names a file, the default destination is that file (with an .err suffix added if the name has no suffix), located under the data directory unless an absolute path name is given to specify a different location.

    如果错误日志输出无法重定向到错误日志文件,将会发生错误并导致启动失败。If error log output cannot be redirected to the error log file, an error occurs and startup fails.

    如果同时给出,则优先于--console在这种情况下,默认的错误日志目标是控制台,而不是文件。--log-error这会产生错误,因为在On Windows, --console takes precedence over --log-error if both are given. In this case, the default error log destination is the console rather than a file.

  • --log-isam[=file_name] --log-isam[=file_name]

    命令行格式Command-Line Format --log-isam[=file_name]--log-isam[=file_name]
    类型Type 文件名File name

    将所有 MyISAM 的更改记录到此文件(仅在调试 MyISAM 时使用)。Log all MyISAM changes to this file (used only when debugging MyISAM).

  • --log-raw

    命令行格式Command-Line Format --log-raw[={OFF|ON}]--log-raw[={OFF|ON}]
    系统变量System Variable log_raw
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    某些语句中的密码写入一般查询日志、慢查询日志和二进制日志时,服务器会重写这些密码,使其不会以明文形式出现。通过使用 --log-raw 选项启动服务器,可以抑制一般查询日志中的密码重写。此选项在诊断时可能有用,可以查看服务器接收的语句的精确文本,但出于安全原因,不推荐在生产环境中使用。Passwords in certain statements written to the general query log, slow query log, and binary log are rewritten by the server not to occur literally in plain text. Password rewriting can be suppressed for the general query log by starting the server with the --log-raw option. This option may be useful for diagnostic purposes, to see the exact text of statements as received by the server, but for security reasons is not recommended for production use.

    如果安装了查询重写插件,--log-raw 选项对语句日志的影响如下:If a query rewrite plugin is installed, the --log-raw option affects statement logging as follows:

    • 如果没有 --log-raw,服务器记录由查询重写插件返回的语句。这可能与接收到的语句不同。Without --log-raw, the server logs the statement returned by the query rewrite plugin. This may differ from the statement as received.

    • 使用 --log-raw 时,服务器记录接收到的原始语句。With --log-raw, the server logs the original statement as received.

    更多信息,请参见 第 8.1.2.3 节,“密码与日志记录”。For more information, see Section 8.1.2.3, “Passwords and Logging”.

  • --log-short-format

    命令行格式Command-Line Format --log-short-format[={OFF|ON}]--log-short-format[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果慢查询日志已被启用,请记录较少的信息。Log less information to the slow query log, if it has been activated.

  • --log-tc=file_name --log-tc=file_name

    命令行格式Command-Line Format --log-tc=file_name--log-tc=file_name
    类型Type 文件名File name
    默认值Default Value tc.log

    内存映射事务协调器日志文件的名称(用于影响多个存储引擎的 XA 事务,当二进制日志被禁用时)。默认名称是 tc.log。如果未提供完整路径名称,则该文件将创建在数据目录下。此选项未使用。The name of the memory-mapped transaction coordinator log file (for XA transactions that affect multiple storage engines when the binary log is disabled). The default name is tc.log. The file is created under the data directory if not given as a full path name. This option is unused.

  • --log-tc-size=size --log-tc-size=size

    命令行格式Command-Line Format --log-tc-size=#
    类型Type 整数Integer
    默认值Default Value 6 * page size6 * page size
    最小值Minimum Value 6 * page size6 * page size
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295

    内存映射事务协调器日志的字节大小。默认值和最小值为页面大小的 6 倍,且该值必须是页面大小的倍数。The size in bytes of the memory-mapped transaction coordinator log. The default and minimum values are 6 times the page size, and the value must be a multiple of the page size.

  • --memlock

    命令行格式Command-Line Format --memlock[={OFF|ON}]--memlock[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    将 mysqld 进程锁定在内存中。如果操作系统导致 mysqld 交换到磁盘,这个选项可能会有所帮助。Lock the mysqld process in memory. This option might help if you have a problem where the operating system is causing mysqld to swap to disk.

    --memlock 在支持 mlockall() 系统调用的系统上可用;这包括 Solaris、大多数使用 2.4 或更高内核的 Linux 发行版,以及可能的其他 Unix 系统。在 Linux 系统上,你可以通过检查系统 mman.h 文件中是否定义了 mlockall()(从而支持此选项)来判断:--memlock works on systems that support the mlockall() system call; this includes Solaris, most Linux distributions that use a 2.4 or higher kernel, and perhaps other Unix systems. On Linux systems, you can tell whether or not mlockall() (and thus this option) is supported by checking to see whether or not it is defined in the system mman.h file, like this:

    $> grep mlockall /usr/include/sys/mman.h
    

    如果支持 mlockall(),你应该在前一个命令的输出中看到如下类似内容:If mlockall() is supported, you should see in the output of the previous command something like the following:

    extern int mlockall (int __flags) __THROW;
    
    Important

    使用此选项可能需要您以 root 身份运行服务器,而出于安全原因,这通常不是一个好主意。参见 第 8.1.5 节,“如何以普通用户身份运行 MySQL”。Use of this option may require you to run the server as root, which, for reasons of security, is normally not a good idea. See Section 8.1.5, “How to Run MySQL as a Normal User”.

    在 Linux 以及可能的其他系统上,您可以通过修改 limits.conf 文件来避免以 root 身份运行服务器的需求。有关 memlock 限制的说明,请参见 第 10.12.3.3 节,“启用大页支持”。On Linux and perhaps other systems, you can avoid the need to run the server as root by changing the limits.conf file. See the notes regarding the memlock limit in Section 10.12.3.3, “Enabling Large Page Support”.

    您不能在不支持 mlockall() 系统调用的系统上使用此选项;如果您这样做,mysqld 很可能会在您尝试启动它时立即退出。You must not use this option on a system that does not support the mlockall() system call; if you do so, mysqld is very likely to exit as soon as you try to start it.

  • --myisam-block-size=N

    命令行格式Command-Line Format --myisam-block-size=#
    类型Type 整数Integer
    默认值Default Value 1024
    最小值Minimum Value 1024
    最大值Maximum Value 16384

    用于 MyISAM 索引页的块大小。The block size to be used for MyISAM index pages.

  • --mysql-native-password

    命令行格式Command-Line Format --mysql-native-password={OFF|ON}--mysql-native-password={OFF|ON}
    已弃用Deprecated 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    启用 mysql_native_password 身份验证插件,在 MySQL 8.4 中默认是禁用的。Enable the mysql_native_password authentication plugin, which is disabled by default in MySQL 8.4.

    有关更多信息,请参见 第 8.4.1.1 节,“本地可插拔身份验证”。For more information, see Section 8.4.1.1, “Native Pluggable Authentication”.

  • --no-defaults

    不要读取任何选项文件。如果程序启动由于从选项文件读取未知选项而失败,可以使用 --no-defaults 来防止读取它们。如果使用此选项,它必须是命令行上的第一个选项。Do not read any option files. If program startup fails due to reading unknown options from an option file, --no-defaults can be used to prevent them from being read. This must be the first option on the command line if it is used.

    有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 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”.

  • --no-monitor

    命令行格式Command-Line Format --no-monitor[={OFF|ON}]--no-monitor[={OFF|ON}]
    特定平台Platform Specific 窗口Windows
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    (仅限 Windows)。此选项抑制用于实现 RESTART 语句的分叉操作:分叉允许一个进程作为监视器来监控另一个作为服务器的进程。对于使用此选项启动的服务器,RESTART 将仅退出而不会重新启动。(Windows only). This option suppresses the forking that is used to implement the RESTART statement: Forking enables one process to act as a monitor to the other, which acts as the server. For a server started with this option, RESTART simply exits and does not restart.

  • --performance-schema-xxx

    配置 Performance Schema 选项。有关详细信息,请参见 第 29.14 节,“Performance Schema 命令选项”。Configure a Performance Schema option. For details, see Section 29.14, “Performance Schema Command Options”.

  • --plugin-load=plugin_list

    命令行格式Command-Line Format --plugin-load=plugin_list
    类型Type 字符串String

    此选项指示服务器在启动时加载指定的插件。如果提供了多个 --plugin-load 选项,则仅最后一个生效。可通过 --plugin-load-add 选项指定其他要加载的插件。This option tells the server to load the named plugins at startup. If multiple --plugin-load options are given, only the last one applies. Additional plugins to load may be specified using --plugin-load-add options.

    该选项值是一个由分号分隔的plugin_library和name=plugin_library值组成的列表。每个plugin_library都是包含插件代码的库文件的名称,每个name是要加载的插件的名称。如果插件库的名称没有前置插件名称,服务器将加载库中的所有插件。如果有前置插件名称,服务器只加载库中命名的插件。服务器在由plugin_dir系统变量指定的目录中查找插件库文件。The option value is a semicolon-separated list of plugin_library and name=plugin_library values. Each plugin_library is the name of a library file that contains plugin code, and each name is the name of a plugin to load. If a plugin library is named without any preceding plugin name, the server loads all plugins in the library. With a preceding plugin name, the server loads only the named plugin from the library. The server looks for plugin library files in the directory named by the plugin_dir system variable.

    例如,如果名为myplug1和myplug2的插件包含在插件库文件myplug1.so和myplug2.so中,请使用此选项执行早期插件加载:For example, if plugins named myplug1 and myplug2 are contained in the plugin library files myplug1.so and myplug2.so, use this option to perform an early plugin load:

    mysqld --plugin-load="myplug1=myplug1.so;myplug2=myplug2.so"
    

    参数值需要用引号括起来,否则某些命令解释器会将分号(;)解释为特殊字符。(例如,Unix shell 将其视为命令终止符。)Quotes surround the argument value because otherwise some command interpreters interpret semicolon (;) as a special character. (For example, Unix shells treat it as a command terminator.)

    每个命名的插件仅在单次调用mysqld时加载。重启后,插件不会被加载,除非再次使用--plugin-load。这与INSTALL PLUGIN不同,后者会向mysql.plugins表中添加一条记录,从而使插件在每次正常服务器启动时加载。Each named plugin is loaded for a single invocation of mysqld only. After a restart, the plugin is not loaded unless --plugin-load is used again. This is in contrast to INSTALL PLUGIN, which adds an entry to the mysql.plugins table to cause the plugin to be loaded for every normal server startup.

    在正常的启动过程中,服务器通过读取 mysql.plugins 系统表来确定要加载哪些插件。如果服务器使用 --skip-grant-tables 选项启动,则 mysql.plugins 表中注册的插件不会被加载,也不可用。--plugin-load 允许即使使用了 --skip-grant-tables 选项,也能加载插件。--plugin-load 还允许在启动时加载那些在运行时无法加载的插件。During the normal startup sequence, the server determines which plugins to load by reading the mysql.plugins system table. If the server is started with the --skip-grant-tables option, plugins registered in the mysql.plugins table are not loaded and are unavailable. --plugin-load enables plugins to be loaded even when --skip-grant-tables is given. --plugin-load also enables plugins to be loaded at startup that cannot be loaded at runtime.

    此选项不会设置相应的系统变量。SHOW PLUGINS 的输出提供有关已加载插件的信息。更多详细信息可以在信息模式的 PLUGINS 表中找到。请参见 第 7.6.2 节,“获取服务器插件信息”。This option does not set a corresponding system variable. The output of SHOW PLUGINS provides information about loaded plugins. More detailed information can be found in the Information Schema PLUGINS table. See Section 7.6.2, “Obtaining Server Plugin Information”.

    有关插件加载的更多信息,请参见 第 7.6.1 节,“安装和卸载插件”。For additional information about plugin loading, see Section 7.6.1, “Installing and Uninstalling Plugins”.

  • --plugin-load-add=plugin_list

    命令行格式Command-Line Format --plugin-load-add=plugin_list
    类型Type 字符串String

    此选项补充了 --plugin-load 选项。--plugin-load-add 在启动时将插件或插件集添加到要加载的插件集合中。参数格式与 --plugin-load 相同。--plugin-load-add 可用于避免将大量插件作为单个冗长笨重的 --plugin-load 参数指定。This option complements the --plugin-load option. --plugin-load-add adds a plugin or plugins to the set of plugins to be loaded at startup. The argument format is the same as for --plugin-load. --plugin-load-add can be used to avoid specifying a large set of plugins as a single long unwieldy --plugin-load argument.

    --plugin-load-add 可以在没有 --plugin-load 的情况下使用,但任何出现在 --plugin-load 之前的 --plugin-load-add 实例都不会生效,因为 --plugin-load 会重置要加载的插件集合。换句话说,这些选项:--plugin-load-add can be given in the absence of --plugin-load, but any instance of --plugin-load-add that appears before --plugin-load has no effect because --plugin-load resets the set of plugins to load. In other words, these options:

    --plugin-load=x --plugin-load-add=y
    

    相当于此选项:are equivalent to this option:

    --plugin-load="x;y"
    

    但这些选项:But these options:

    --plugin-load-add=y --plugin-load=x
    

    相当于此选项:are equivalent to this option:

    --plugin-load=x
    

    此选项不会设置相应的系统变量。SHOW PLUGINS 的输出提供有关已加载插件的信息。更多详细信息可以在信息模式的 PLUGINS 表中找到。请参见 第 7.6.2 节,“获取服务器插件信息”。This option does not set a corresponding system variable. The output of SHOW PLUGINS provides information about loaded plugins. More detailed information can be found in the Information Schema PLUGINS table. See Section 7.6.2, “Obtaining Server Plugin Information”.

    有关插件加载的更多信息,请参见 第 7.6.1 节,“安装和卸载插件”。For additional information about plugin loading, see Section 7.6.1, “Installing and Uninstalling Plugins”.

  • --plugin-xxx

    指定与服务器插件相关的选项。例如,许多存储引擎可以作为插件构建,对于这样的引擎,可以使用 --plugin 前缀来指定它们的选项。因此,InnoDB 的 --innodb-file-per-table 选项可以指定为 --plugin-innodb-file-per-table。Specifies an option that pertains to a server plugin. For example, many storage engines can be built as plugins, and for such engines, options for them can be specified with a --plugin prefix. Thus, the --innodb-file-per-table option for InnoDB can be specified as --plugin-innodb-file-per-table.

    对于可以启用或禁用的布尔选项,也支持 --skip 前缀和其他替代格式(请参见 第 6.2.2.4 节,“程序选项修饰符”)。例如,--skip-plugin-innodb-file-per-table 禁用 innodb-file-per-table。For boolean options that can be enabled or disabled, the --skip prefix and other alternative formats are supported as well (see Section 6.2.2.4, “Program Option Modifiers”). For example, --skip-plugin-innodb-file-per-table disables innodb-file-per-table.

    --plugin 前缀的原理是,当插件选项与内置服务器选项名称冲突时,可以明确指定插件选项。例如,如果插件开发者将插件命名为 “sql” 并实现一个 “mode” 选项,则该选项名称可能为 --sql-mode,这将与同名的内置选项冲突。在这种情况下,对冲突名称的引用将优先解析为内置选项。为了避免歧义,用户可以将插件选项指定为 --plugin-sql-mode。建议为插件选项使用 --plugin 前缀,以避免任何歧义问题。The rationale for the --plugin prefix is that it enables plugin options to be specified unambiguously if there is a name conflict with a built-in server option. For example, were a plugin writer to name a plugin “sql” and implement a “mode” option, the option name might be --sql-mode, which would conflict with the built-in option of the same name. In such cases, references to the conflicting name are resolved in favor of the built-in option. To avoid the ambiguity, users can specify the plugin option as --plugin-sql-mode. Use of the --plugin prefix for plugin options is recommended to avoid any question of ambiguity.

  • --port=port_num, -P port_num

    命令行格式Command-Line Format --port=port_num--port=port_num
    系统变量System Variable portport
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 3306
    最小值Minimum Value 0
    最大值Maximum Value 65535

    监听 TCP/IP 连接时使用的端口号。在 Unix 和类 Unix 系统上,除非服务器由 root 操作系统用户启动,否则端口号必须为 1024 或更高。将此选项设置为 0 会使用默认值。The port number to use when listening for TCP/IP connections. On Unix and Unix-like systems, the port number must be 1024 or higher unless the server is started by the root operating system user. Setting this option to 0 causes the default value to be used.

  • --port-open-timeout=num

    命令行格式Command-Line Format --port-open-timeout=#
    类型Type 整数Integer
    默认值Default Value 0

    在某些系统上,当服务器停止时,TCP/IP 端口可能不会立即可用。如果随后迅速重启服务器,重新打开端口的尝试可能会失败。此选项指示服务器在无法打开 TCP/IP 端口时,应等待多少秒以使端口变为可用。默认是不给予等待。On some systems, when the server is stopped, the TCP/IP port might not become available immediately. If the server is restarted quickly afterward, its attempt to reopen the port can fail. This option indicates how many seconds the server should wait for the TCP/IP port to become free if it cannot be opened. The default is not to wait.

  • --print-defaults

    打印程序名称及其从选项文件获取的所有选项。密码值将被屏蔽。如果使用此选项,它必须是命令行上的第一个选项,除非它紧接在 --defaults-file 或 --defaults-extra-file 之后使用。Print the program name and all options that it gets from option files. Password values are masked. This must be the first option on the command line if it is used, except that it may be used immediately after --defaults-file or --defaults-extra-file.

    有关此选项文件选项及其他选项文件选项的更多信息,请参见 第 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”.

  • --remove [service_name]

    命令行格式Command-Line Format --remove [service_name]
    特定平台Platform Specific 窗口Windows

    (仅限 Windows)删除 MySQL Windows 服务。如果未提供 service_name 值,默认服务名称为 MySQL。更多信息,请参见 第 2.3.3.8 节,“作为 Windows 服务启动 MySQL”。(Windows only) Remove a MySQL Windows service. The default service name is MySQL if no service_name value is given. For more information, see Section 2.3.3.8, “Starting MySQL as a Windows Service”.

  • --safe-user-create

    命令行格式Command-Line Format --safe-user-create[={OFF|ON}]
    已弃用Deprecated 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果启用此选项,用户不能使用 GRANT 语句创建新的 MySQL 用户,除非该用户对 mysql.user 系统表或表中的任一列拥有 INSERT 权限。如果您希望某个用户能够创建具有其有权授予的权限的新用户,则应向该用户授予以下权限:If this option is enabled, a user cannot create new MySQL users by using the GRANT statement unless the user has the INSERT privilege for the mysql.user system table or any column in the table. If you want a user to have the ability to create new users that have those privileges that the user has the right to grant, you should grant the user the following privilege:

    GRANT INSERT(user) ON mysql.user TO 'user_name'@'host_name';
    

    这确保用户不能直接更改任何权限列,而必须使用 GRANT 语句来授予其他用户权限。This ensures that the user cannot change any privilege columns directly, but has to use the GRANT statement to give privileges to other users.

  • --skip-grant-tables

    命令行格式Command-Line Format --skip-grant-tables[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此选项会影响服务器启动顺序:This option affects the server startup sequence:

  • --skip-new

    命令行格式Command-Line Format --skip-new
    已弃用Deprecated 是Yes

    此选项禁用(以前被认为是)新的、可能不安全的行为。它会产生以下设置:delay_key_write=OFF,concurrent_insert=NEVER,automatic_sp_privileges=OFF。它还会导致OPTIMIZE TABLE被映射到ALTER TABLE,适用于不支持OPTIMIZE TABLE的存储引擎。This option disables (what used to be considered) new, possibly unsafe behaviors. It results in these settings: delay_key_write=OFF, concurrent_insert=NEVER, automatic_sp_privileges=OFF. It also causes OPTIMIZE TABLE to be mapped to ALTER TABLE for storage engines for which OPTIMIZE TABLE is not supported.

    此选项已被弃用,并可能在未来版本中移除。This option is deprecated, and subject to removal in a future release.

  • --skip-show-database

    命令行格式Command-Line Format --skip-show-database
    系统变量System Variable skip_show_database
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此选项设置 skip_show_database 系统变量,该变量控制谁被允许使用 SHOW DATABASES 语句。参见 第 7.1.8 节,“服务器系统变量”。This option sets the skip_show_database system variable that controls who is permitted to use the SHOW DATABASES statement. See Section 7.1.8, “Server System Variables”.

  • --skip-stack-trace

    命令行格式Command-Line Format --skip-stack-trace

    不写堆栈跟踪。当你在调试器下运行 mysqld 时,此选项很有用。在某些系统上,你还必须使用此选项才能获得 core 文件。参见 第 7.9 节,“调试 MySQL”。Do not write stack traces. This option is useful when you are running mysqld under a debugger. On some systems, you also must use this option to get a core file. See Section 7.9, “Debugging MySQL”.

  • --slow-start-timeout=timeout --slow-start-timeout=timeout

    命令行格式Command-Line Format --slow-start-timeout=#
    类型Type 整数Integer
    默认值Default Value 15000

    此选项控制 Windows 服务控制管理器的服务启动超时。该值是服务控制管理器在尝试在启动期间终止 Windows 服务之前等待的最长毫秒数。默认值为 15000(15 秒)。如果 MySQL 服务启动时间过长,您可能需要增加此值。值为 0 表示没有超时。This option controls the Windows service control manager's service start timeout. The value is the maximum number of milliseconds that the service control manager waits before trying to kill the windows service during startup. The default value is 15000 (15 seconds). If the MySQL service takes too long to start, you may need to increase this value. A value of 0 means there is no timeout.

  • --socket=path --socket=path

    命令行格式Command-Line Format --socket={file_name|pipe_name}--socket={file_name|pipe_name}
    系统变量System Variable socket
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值(Windows)Default Value (Windows) MySQLMySQL
    默认值(其他)Default Value (Other) /tmp/mysql.sock/tmp/mysql.sock

    在 Unix 系统上,该选项指定在监听本地连接时使用的 Unix 套接字文件。默认值是 /tmp/mysql.sock。如果提供了此选项,服务器将在数据目录中创建该文件,除非提供了绝对路径以指定不同的目录。在 Windows 上,该选项指定在使用命名管道监听本地连接时使用的管道名称。默认值是 MySQL(不区分大小写)。On Unix, this option specifies the Unix socket file to use when listening for local connections. The default value is /tmp/mysql.sock. If this option is given, the server creates the file in the data directory unless an absolute path name is given to specify a different directory. On Windows, the option specifies the pipe name to use when listening for local connections that use a named pipe. The default value is MySQL (not case-sensitive).

  • --sql-mode=value[,value[,value...]] --sql-mode=value[,value[,value...]]

    命令行格式Command-Line Format --sql-mode=name--sql-mode=name
    系统变量System Variable sql_mode
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 设置Set
    默认值Default Value ONLY_FULL_GROUP_BY STRICT_TRANS_TABLES NO_ZERO_IN_DATE NO_ZERO_DATE ERROR_FOR_DIVISION_BY_ZERO NO_ENGINE_SUBSTITUTIONONLY_FULL_GROUP_BY STRICT_TRANS_TABLES NO_ZERO_IN_DATE NO_ZERO_DATE ERROR_FOR_DIVISION_BY_ZERO NO_ENGINE_SUBSTITUTION
    有效值Valid Values

    ALLOW_INVALID_DATESALLOW_INVALID_DATES

    ANSI_QUOTESANSI_QUOTES

    ERROR_FOR_DIVISION_BY_ZEROERROR_FOR_DIVISION_BY_ZERO

    HIGH_NOT_PRECEDENCEHIGH_NOT_PRECEDENCE

    IGNORE_SPACEIGNORE_SPACE

    NO_AUTO_VALUE_ON_ZERONO_AUTO_VALUE_ON_ZERO

    NO_BACKSLASH_ESCAPESNO_BACKSLASH_ESCAPES

    NO_DIR_IN_CREATENO_DIR_IN_CREATE

    NO_ENGINE_SUBSTITUTIONNO_ENGINE_SUBSTITUTION

    NO_UNSIGNED_SUBTRACTIONNO_UNSIGNED_SUBTRACTION

    NO_ZERO_DATENO_ZERO_DATE

    NO_ZERO_IN_DATENO_ZERO_IN_DATE

    ONLY_FULL_GROUP_BYONLY_FULL_GROUP_BY

    PAD_CHAR_TO_FULL_LENGTHPAD_CHAR_TO_FULL_LENGTH

    PIPES_AS_CONCATPIPES_AS_CONCAT

    REAL_AS_FLOATREAL_AS_FLOAT

    STRICT_ALL_TABLESSTRICT_ALL_TABLES

    STRICT_TRANS_TABLESSTRICT_TRANS_TABLES

    TIME_TRUNCATE_FRACTIONALTIME_TRUNCATE_FRACTIONAL

    设置 SQL 模式。参见 第 7.1.11 节,“服务器 SQL 模式”。Set the SQL mode. See Section 7.1.11, “Server SQL Modes”.

    Note

    MySQL 安装程序可能会在安装过程中配置 SQL 模式。MySQL installation programs may configure the SQL mode during the installation process.

    如果 SQL 模式与默认值或您预期的不同,请检查服务器在启动时读取的选项文件中的设置。If the SQL mode differs from the default or from what you expect, check for a setting in an option file that the server reads at startup.

  • --standalone

    命令行格式Command-Line Format --standalone
    特定平台Platform Specific 窗口Windows

    仅适用于 Windows;指示 MySQL 服务器不要以服务方式运行。Available on Windows only; instructs the MySQL server not to run as a service.

  • --super-large-pages

    命令行格式Command-Line Format --super-large-pages[={OFF|ON}]--super-large-pages[={OFF|ON}]
    特定平台Platform Specific 太阳神Solaris
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    Standard use of large pages in MySQL attempts to use the largest size supported, up to 4MB. Under Solaris, a “super large pages” feature enables uses of pages up to 256MB. This feature is available for recent SPARC platforms. It can be enabled or disabled by using the --super-large-pages或者--skip-super-large-pages同步调试检查Standard use of large pages in MySQL attempts to use the largest size supported, up to 4MB. Under Solaris, a “super large pages” feature enables uses of pages up to 256MB. This feature is available for recent SPARC platforms. It can be enabled or disabled by using the --super-large-pages or --skip-super-large-pages option.

  • --symbolic-links, --skip-symbolic-links

    命令行格式Command-Line Format --symbolic-links[={OFF|ON}]
    已弃用Deprecated 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    Enable or disable symbolic link support. On Unix, enabling symbolic links means that you can link a MyISAM index file or data file to another directory with the INDEX DIRECTORY或者DATA DIRECTORY option of the CREATE TABLE statement. If you delete or rename the table, the files that its symbolic links point to also are deleted or renamed. See Section 10.12.2.2, “Using Symbolic Links for MyISAM Tables on Unix”.Enable or disable symbolic link support. On Unix, enabling symbolic links means that you can link a MyISAM index file or data file to another directory with the INDEX DIRECTORY or DATA DIRECTORY option of the CREATE TABLE statement. If you delete or rename the table, the files that its symbolic links point to also are deleted or renamed. See Section 10.12.2.2, “Using Symbolic Links for MyISAM Tables on Unix”.

    Note

    符号链接支持,以及用于控制它的 --symbolic-links 选项,已被弃用;你应该预期它将在未来的 MySQL 版本中被移除。此外,该选项默认情况下是禁用的。相关的 have_symlink 系统变量也已被弃用;预期将在未来的 MySQL 版本中被移除。Symbolic link support, along with the --symbolic-links option that controls it, is deprecated; you should expect it to be removed in a future version of MySQL. In addition, the option is disabled by default. The related have_symlink system variable also is deprecated; expect it to be removed in a future version of MySQL.

    此选项在 Windows 上没有意义。This option has no meaning on Windows.

  • --sysdate-is-now

    命令行格式Command-Line Format --sysdate-is-now[={OFF|ON}]--sysdate-is-now[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    SYSDATE() 默认返回其执行时的时间,而不是其所在语句开始执行的时间。这与 NOW() 的行为不同。此选项会使 SYSDATE() 成为 NOW() 的同义词。有关二进制日志记录和复制的影响,请参见 SYSDATE() 在 第 14.7 节,“日期和时间函数” 中的描述,以及 SET TIMESTAMP 在 第 7.1.8 节,“服务器系统变量” 中的描述。SYSDATE() by default returns the time at which it executes, not the time at which the statement in which it occurs begins executing. This differs from the behavior of NOW(). This option causes SYSDATE() to be a synonym for NOW(). For information about the implications for binary logging and replication, see the description for SYSDATE() in Section 14.7, “Date and Time Functions” and for SET TIMESTAMP in Section 7.1.8, “Server System Variables”.

  • --tc-heuristic-recover={COMMIT|ROLLBACK} --tc-heuristic-recover={COMMIT|ROLLBACK}

    命令行格式Command-Line Format --tc-heuristic-recover=name--tc-heuristic-recover=name
    类型Type 枚举Enumeration
    默认值Default Value OFFOFF
    有效值Valid Values

    OFFOFF

    COMMITCOMMIT

    ROLLBACKROLLBACK

    决定使用手动启发式恢复。The decision to use in a manual heuristic recovery.

    如果指定了 --tc-heuristic-recover 选项,无论手动启发式恢复是否成功,服务器都会退出。If a --tc-heuristic-recover option is specified, the server exits regardless of whether manual heuristic recovery is successful.

    在具有多个能够进行两阶段提交的存储引擎的系统上,ROLLBACK 选项不安全,并会导致恢复因以下错误而中止:On systems with more than one storage engine capable of two-phase commit, the ROLLBACK option is not safe and causes recovery to halt with the following error:

    [ERROR] --tc-heuristic-recover rollback
    strategy is not safe on systems with more than one 2-phase-commit-capable
    storage engine. Aborting crash recovery.
  • --transaction-isolation=level

    命令行格式Command-Line Format --transaction-isolation=name
    系统变量System Variable transaction_isolation
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value REPEATABLE-READREPEATABLE-READ
    有效值Valid Values

    READ-UNCOMMITTEDREAD-UNCOMMITTED

    READ-COMMITTEDREAD-COMMITTED

    REPEATABLE-READREPEATABLE-READ

    SERIALIZABLESERIALIZABLE

    设置默认事务隔离级别。level 值可以是 READ-UNCOMMITTED、READ-COMMITTED、REPEATABLE-READ 或 SERIALIZABLE。参见 第 15.3.7 节,“SET TRANSACTION 语句”。Sets the default transaction isolation level. The level value can be READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, or SERIALIZABLE. See Section 15.3.7, “SET TRANSACTION Statement”.

    默认的事务隔离级别也可以在运行时使用SET TRANSACTION语句设置,或者通过设置transaction_isolation系统变量来设置。The default transaction isolation level can also be set at runtime using the SET TRANSACTION statement or by setting the transaction_isolation system variable.

  • --transaction-read-only

    命令行格式Command-Line Format --transaction-read-only[={OFF|ON}]
    系统变量System Variable transaction_read_only
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    设置默认的事务访问模式。默认情况下,只读模式是禁用的,因此模式为读/写。Sets the default transaction access mode. By default, read-only mode is disabled, so the mode is read/write.

    要在运行时设置默认事务访问模式,请使用 SET TRANSACTION 语句,或设置 transaction_read_only 系统变量。参见 第 15.3.7 节,“SET TRANSACTION 语句”。To set the default transaction access mode at runtime, use the SET TRANSACTION statement or set the transaction_read_only system variable. See Section 15.3.7, “SET TRANSACTION Statement”.

  • --tmpdir=dir_name, -t dir_name --tmpdir=dir_name, -t dir_name

    命令行格式Command-Line Format --tmpdir=dir_name--tmpdir=dir_name
    系统变量System Variable tmpdir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name

    用于创建临时文件的目录路径。如果您的默认 /tmp 目录所在的分区太小,无法容纳临时表,这可能会很有用。此选项可以接受多个路径,这些路径将按轮询的方式使用。在 Unix 系统上,路径应使用冒号字符 (:) 分隔;在 Windows 系统上,则应使用分号字符 (;) 分隔。The path of the directory to use for creating temporary files. It might be useful if your default /tmp directory resides on a partition that is too small to hold temporary tables. This option accepts several paths that are used in round-robin fashion. Paths should be separated by colon characters (:) on Unix and semicolon characters (;) on Windows.

    --tmpdir 可以是一个非永久性的位置,例如基于内存的文件系统上的目录,或者服务器主机重启时会被清理的目录。如果 MySQL 服务器充当副本,并且您为 --tmpdir 使用了非永久位置,请考虑使用 replica_load_tmpdir 系统变量为副本设置不同的临时目录。对于副本,用于复制 LOAD DATA 语句的临时文件会存储在此目录中,因此如果使用永久位置,它们可以在机器重启后保留,尽管如果临时文件已被删除,重启后复制现在也可以继续进行。--tmpdir can be a non-permanent location, such as a directory on a memory-based file system or a directory that is cleared when the server host restarts. If the MySQL server is acting as a replica, and you are using a non-permanent location for --tmpdir, consider setting a different temporary directory for the replica using the replica_load_tmpdir system variable. For a replica, the temporary files used to replicate LOAD DATA statements are stored in this directory, so with a permanent location they can survive machine restarts, although replication can now continue after a restart if the temporary files have been removed.

    有关临时文件存储位置的更多信息,请参见 第 B.3.3.5 节,“MySQL 存储临时文件的位置”。For more information about the storage location of temporary files, see Section B.3.3.5, “Where MySQL Stores Temporary Files”.

  • --upgrade=value --upgrade=value

    命令行格式Command-Line Format --upgrade=value--upgrade=value
    类型Type 枚举Enumeration
    默认值Default Value AUTOAUTO
    有效值Valid Values

    AUTOAUTO

    NONENONE

    MINIMALMINIMAL

    FORCEFORCE

    此选项控制服务器是否以及如何在启动时执行自动升级。自动升级包括两个步骤:This option controls whether and how the server performs an automatic upgrade at startup. Automatic upgrade involves two steps:

    • 步骤 1:数据字典升级。Step 1: Data dictionary upgrade.

      此步骤升级:This step upgrades:

      • mysql 模式中的数据字典表。如果实际的数据字典版本低于当前预期版本,服务器会升级数据字典。如果无法升级,或者被阻止升级,服务器将无法运行。The data dictionary tables in the mysql schema. If the actual data dictionary version is lower than the current expected version, the server upgrades the data dictionary. If it cannot, or is prevented from doing so, the server cannot run.

      • 性能模式和 INFORMATION_SCHEMA。The Performance Schema and INFORMATION_SCHEMA.

    • 步骤 2:服务器升级。Step 2: Server upgrade.

      此步骤包括所有其他升级任务。如果现有安装数据的 MySQL 版本低于服务器预期版本,则必须进行升级:This step comprises all other upgrade tasks. If the existing installation data has a lower MySQL version than the server expects, it must be upgraded:

      • mysql 模式中的系统表(其余非数据字典表)。The system tables in the mysql schema (the remaining non-data dictionary tables).

      • sys 模式。The sys schema.

      • 用户模式。User schemas.

    有关升级步骤 1 和 2 的详细信息,请参见 第 3.4 节,“MySQL 升级过程升级的内容”。For details about upgrade steps 1 and 2, see Section 3.4, “What the MySQL Upgrade Process Upgrades”.

    允许使用这些 --upgrade 选项值:These --upgrade option values are permitted:

    • AUTOAUTO

      服务器会自动升级它发现的所有过时内容(步骤 1 和 2)。如果未明确指定 --upgrade,则这是默认操作。The server performs an automatic upgrade of anything it finds to be out of date (steps 1 and 2). This is the default action if --upgrade is not specified explicitly.

    • NONENONE

      服务器在启动过程中不会执行任何自动升级步骤(跳过步骤 1 和 2)。由于此选项值阻止数据字典升级,如果发现数据字典已过时,服务器将以错误退出:The server performs no automatic upgrade steps during the startup process (skips steps 1 and 2). Because this option value prevents a data dictionary upgrade, the server exits with an error if the data dictionary is found to be out of date:

      [ERROR] [MY-013381] [Server] Server shutting down because upgrade is
      required, yet prohibited by the command line option '--upgrade=NONE'.
      [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
      [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
      
    • MINIMALMINIMAL

      如果有必要,服务器会升级数据字典、性能模式(Performance Schema)和 INFORMATION_SCHEMA(步骤 1)。请注意,在使用此选项升级后,无法启动组复制(Group Replication),因为复制内部依赖的系统表未更新,并且在其他区域可能也会出现功能受限的情况。The server upgrades the data dictionary, the Performance Schema, and the INFORMATION_SCHEMA, if necessary (step 1). Note that following an upgrade with this option, Group Replication cannot be started, because system tables on which the replication internals depend are not updated, and reduced functionality might also be apparent in other areas.

    • FORCEFORCE

      如果有必要,服务器会升级数据字典、性能模式(Performance Schema)和 INFORMATION_SCHEMA(步骤 1)。此外,服务器会强制升级其他所有内容(步骤 2)。使用此选项时预计服务器启动会更慢,因为服务器会检查所有模式中的所有对象。The server upgrades the data dictionary, the Performance Schema, and the INFORMATION_SCHEMA, if necessary (step 1). In addition, the server forces an upgrade of everything else (step 2). Expect server startup to take longer with this option because the server checks all objects in all schemas.

      FORCE 用于在服务器认为不必要时强制执行步骤 2 的操作。例如,你可能认为某个系统表缺失或已损坏,并希望强制进行修复。FORCE is useful to force step 2 actions to be performed if the server thinks they are not necessary. For example, you may believe that a system table is missing or has become damaged and want to force a repair.

    下表总结了服务器针对每个选项值所采取的操作。The following table summarizes the actions taken by the server for each option value.

    选项值Option Value 服务器执行步骤 1?Server Performs Step 1? 服务器执行步骤 2?Server Performs Step 2?
    AUTOAUTO 如有必要If necessary 如有必要If necessary
    NONENONE 否No 否No
    MINIMALMINIMAL 如有必要If necessary 否No
    FORCEFORCE 如有必要If necessary 是Yes
  • --user={user_name|user_id}, -u {user_name|user_id} --user={user_name|user_id}, -u {user_name|user_id}

    命令行格式Command-Line Format --user=name--user=name
    类型Type 字符串String

    或数字用户 IDmysqld的用户身份运行user_name服务器user_id. (“用户”在此上下文中指的是系统登录账户,而不是授予表中列出的 MySQL 用户。Run the mysqld server as the user having the name user_name or the numeric user ID user_id. (“User” in this context refers to a system login account, not a MySQL user listed in the grant tables.)

    在以 mysqld 作为 root 启动时,此选项是 必须的。服务器在启动过程中会更改其用户 ID,从而以该特定用户身份运行,而不是以 root 身份运行。参见 第 8.1.1 节,“安全指南”。This option is mandatory when starting mysqld as root. The server changes its user ID during its startup sequence, causing it to run as that particular user rather than as root. See Section 8.1.1, “Security Guidelines”.

    为了避免可能出现的安全漏洞,即用户在 my.cnf 文件中添加 --user=root 选项(从而导致服务器以 root 身份运行),mysqld 仅使用指定的第一个 --user 选项,并且如果存在多个 --user 选项会发出警告。 /etc/my.cnf 和 $MYSQL_HOME/my.cnf 中的选项会在命令行选项之前被处理,因此推荐将 --user 选项放在 /etc/my.cnf 中,并指定一个非 root 的值。位于 /etc/my.cnf 中的选项会在其他任何 --user 选项之前被找到,从而确保服务器以非 root 用户运行,并且如果发现任何其他 --user 选项会产生警告。To avoid a possible security hole where a user adds a --user=root option to a my.cnf file (thus causing the server to run as root), mysqld uses only the first --user option specified and produces a warning if there are multiple --user options. Options in /etc/my.cnf and $MYSQL_HOME/my.cnf are processed before command-line options, so it is recommended that you put a --user option in /etc/my.cnf and specify a value other than root. The option in /etc/my.cnf is found before any other --user options, which ensures that the server runs as a user other than root, and that a warning results if any other --user option is found.

  • --validate-config

    命令行格式Command-Line Format --validate-config[={OFF|ON}]--validate-config[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    验证服务器启动配置。如果未发现任何错误,服务器将以退出代码 0 终止。如果发现错误,服务器将显示诊断消息并以退出代码 1 终止。根据 log_error_verbosity 的值,可能还会显示警告和信息消息,但不会立即造成验证终止或产生退出代码 1。有关更多信息,请参见 第 7.1.3 节,“服务器配置验证”。Validate the server startup configuration. If no errors are found, the server terminates with an exit code of 0. If an error is found, the server displays a diagnostic message and terminates with an exit code of 1. Warning and information messages may also be displayed, depending on the log_error_verbosity value, but do not produce immediate validation termination or an exit code of 1. For more information, see Section 7.1.3, “Server Configuration Validation”.

  • --validate-user-plugins[={OFF|ON}] --validate-user-plugins[={OFF|ON}]

    命令行格式Command-Line Format --validate-user-plugins[={OFF|ON}]--validate-user-plugins[={OFF|ON}]
    类型Type 布尔Boolean
    默认值Default Value ONON

    如果启用此选项(默认设置),服务器会检查每个用户账户,并在发现可能导致账户无法使用的条件时发出警告:If this option is enabled (the default), the server checks each user account and produces a warning if conditions are found that would make the account unusable:

    • 该账户需要未加载的认证插件。The account requires an authentication plugin that is not loaded.

    • 该账户需要 sha256_password(已弃用)或 caching_sha2_password 认证插件,但服务器启动时未启用插件所需的 SSL 或 RSA。The account requires the sha256_password (deprecated) or caching_sha2_password authentication plugin but the server was started with neither SSL nor RSA enabled as required by the plugin.

    启用 --validate-user-plugins 会降低服务器初始化速度和 FLUSH PRIVILEGES。如果您不需要额外的检查,可以在启动时禁用此选项以避免性能下降。Enabling --validate-user-plugins slows down server initialization and FLUSH PRIVILEGES. If you do not require the additional checking, you can disable this option at startup to avoid the performance decrement.

  • --verbose, -v

    使用此选项与 --help 选项一起以获取详细帮助。Use this option with the --help option for detailed help.

  • --version, -V

    显示版本信息并退出。Display version information and exit.