当您启动 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:
影响安全性的选项:请参阅 第 8.1.4 节,“与 mysqld 安全相关的选项和变量”。Options that affect security: See Section 8.1.4, “Security-Related mysqld Options and Variables”.
SSL 相关选项:请参阅 加密连接的命令选项。SSL-related options: See Command Options for Encrypted Connections.
二进制日志控制选项:请参阅 第 7.4.4 节,“二进制日志”。Binary log control options: See Section 7.4.4, “The Binary Log”.
复制相关选项:请参阅 第 19.1.6 节,“复制和二进制日志选项及变量”。Replication-related options: See Section 19.1.6, “Replication and Binary Logging Options and Variables”.
加载插件(如可插拔存储引擎)的选项:参见第 7.6.1 节,“安装和卸载插件”。Options for loading plugins such as pluggable storage engines: See Section 7.6.1, “Installing and Uninstalling Plugins”.
特定存储引擎的选项:参见第 17.14 节,“InnoDB 启动选项和系统变量”以及第 18.2.1 节,“MyISAM 启动选项”。Options specific to particular storage engines: See Section 17.14, “InnoDB Startup Options and System Variables” and Section 18.2.1, “MyISAM Startup Options”.
有些选项控制缓冲区或缓存的大小。对于给定的缓冲区,服务器可能需要分配内部数据结构。这些结构通常是从分配给缓冲区的总内存中分配的,并且所需空间的数量可能依赖于平台。这意味着当你为控制缓冲区大小的选项分配一个值时,实际上可用的空间可能与分配的值不同。在某些情况下,可用空间可能小于分配的值。服务器也可能将值向上调整。例如,如果你为一个最小值为 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
--.
For example,
var_name=value--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-。To restrict the maximum value to which a system variable can be
set at runtime with the
var_name=valueSET
statement, specify this maximum by using an option of the form
--maximum-
at server startup.var_name=value
您可以使用 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--verboseand--helpoptions to see the full message.命令行格式Command-Line Format --allow-suspicious-udfs[={OFF|ON}]类型Type 布尔Boolean 默认值Default Value OFFOFF此选项控制是否可以加载主函数仅具有
xxx符号的可加载函数。默认情况下,此选项为关闭,只有具有至少一个辅助符号的可加载函数可以加载;这可以防止尝试从除包含合法函数之外的共享对象文件加载函数。请参阅 可加载函数安全预防措施。This option controls whether loadable functions that have only anxxxsymbol 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.命令行格式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-modeoption 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-bdir_name命令行格式Command-Line Format --basedir=dir_name--basedir=dir_name系统变量System Variable basedir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 默认值Default Value parent of mysqld installation directoryparent of mysqld installation directoryMySQL 安装目录的路径。此选项设置
basedir系统变量。The path to the MySQL installation directory. This option sets thebasedirsystem 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 defaultbasedirvalue. This in turn enables the server to use thatbasedirwhen searching for server-related information such as thesharedirectory 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 WARNWARNABORTABORT在执行服务器升级时,我们会扫描数据字典中在表约束和其他表达式中使用的函数,包括
DEFAULT表达式、分区表达式和虚拟列。函数行为的变化可能会导致在新版本服务器中出现错误,而在之前版本中没有此类错误,这种情况下表无法打开。此选项提供了一种处理此类问题的方式,根据这里显示的两个值之一进行选择:When performing an upgade of the server, we scan the data dictionary for functions used in table constraints and other expressions, includingDEFAULTexpressions, 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. UseWARNto continue the upgrade in interactive mode while reporting any issues.--check-table-functions选项首次引入于 MySQL 8.4.5。The--check-table-functionsoption was introduced in MySQL 8.4.5.--chroot=,dir_name-rdir_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 thechroot()system call. This is a recommended security measure. Use of this option somewhat limitsLOAD DATAandSELECT ... INTO OUTFILE.命令行格式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,如果两者同时给出。--consoletakes precedence over--log-errorif both are given.命令行格式Command-Line Format --core-file当使用此选项时,如果mysqld 崩溃,将生成核心文件;无需(也不接受)任何参数。核心文件的名称和位置取决于操作系统。在 Linux 上,名为
core.的核心文件将写入进程的当前工作目录,对于 mysqld 来说,即数据目录。pidpid代表服务器进程的进程 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 namedcore.is written to the current working directory of the process, which for mysqld is the data directory.pidpidrepresents the process ID of the server process. On macOS, a core file namedcore.is written to thepid/coresdirectory. 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-sizeoption 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--useroption. 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 节,“从核心文件中排除或包含缓冲池页”。Theinnodb_buffer_pool_in_core_filevariable 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互斥。--daemonizeis mutually exclusive with--initializeand--initialize-insecure.如果使用
--daemonize选项启动服务器并且没有连接到 tty 设备,在没有明确指定日志选项的情况下,将使用默认的错误日志选项--log-error="",以将错误输出写入默认日志文件。If the server is started using the--daemonizeoption 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的同义词。-Dis a synonym for--daemonize.--datadir=dir_name,-h dir_name--datadir=,dir_name-hdir_name命令行格式Command-Line Format --datadir=dir_name--datadir=dir_name系统变量System Variable datadir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name MySQL 服务器数据目录的路径。此选项设置
datadir系统变量。请参阅该变量的描述。The path to the MySQL server data directory. This option sets thedatadirsystem 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_VARHint 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=1CMake 选项,你可以使用此选项获取 mysqld 正在执行操作的跟踪文件。典型的debug_options字符串是d:t:o,。默认值在 Unix 上是file_named:t:i:o,/tmp/mysqld.trace,在 Windows 上是d:t:i:O,\mysqld.trace。If MySQL is configured with the-DWITH_DEBUG=1CMake option, you can use this option to get a trace file of what mysqld is doing. A typicaldebug_optionsstring isd:t:o,. The default isfile_named:t:i:o,/tmp/mysqld.traceon Unix andd:t:i:O,\mysqld.traceon Windows.使用
-DWITH_DEBUG=1配置带有调试支持的 MySQL,可在启动服务器时使用--debug="d,parser_debug"选项。这会导致用于处理 SQL 语句的 Bison 解析器将解析器跟踪信息输出到服务器的标准错误输出。通常,这些输出会写入错误日志。Using-DWITH_DEBUG=1to 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=+Psets the value toP:T.更多信息,请参阅 第 7.9.4 节,“DBUG 包”。For more information, see Section 7.9.4, “The DBUG Package”.
命令行格式Command-Line Format --debug-sync-timeout[=#]类型Type 整数Integer 控制是否启用用于测试和调试的 Debug Sync 功能。使用 Debug Sync 需要 MySQL 使用
-DWITH_DEBUG=ONCMake 选项进行配置(参见 第 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=ONCMake 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 globaltime_zonesystem variable. If this option is not given, the default time zone is the same as the system time zone (given by the value of thesystem_time_zonesystem variable.system_time_zone变量不同于time_zone。虽然它们可能具有相同的值,但后者变量用于初始化每个连接客户端的时区。请参见 第 7.1.15 节,“MySQL 服务器时区支持”。Thesystem_time_zonevariable differs fromtime_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. Iffile_nameis 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. Iffile_nameis 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 readsmysqld-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-fileand--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”.
不仅读取常规的选项组,还读取具有常规名称且后缀为
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 ofstr. 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 withPLUGIN_OPT_ALLOW_EARLY. If multiple--early-plugin-loadoptions 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 ofplugin_libraryandname=plugin_libraryvalues. Eachplugin_libraryis the name of a library file that contains plugin code, and eachnameis 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 theplugin_dirsystem variable.例如,如果名为
myplug1和myplug2的插件包含在插件库文件myplug1.so和myplug2.so中,请使用此选项执行早期插件加载:For example, if plugins namedmyplug1andmyplug2are contained in the plugin library filesmyplug1.soandmyplug2.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-loadis used again.如果服务器使用
--initialize或--initialize-insecure启动,则由--early-plugin-load指定的插件不会被加载。If the server is started using--initializeor--initialize-insecure, plugins specified by--early-plugin-loadare not loaded.如果服务器使用
--help运行,则由--early-plugin-load指定的插件会被加载但不会初始化。此行为确保插件选项显示在帮助信息中。If the server is run with--help, plugins specified by--early-plugin-loadare 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)。InnoDBtablespace 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 facilitateInnoDBrecovery for encrypted tables. For example, administrators who want thekeyring_okvplugin loaded at startup should use--early-plugin-loadwith the appropriate option value (such askeyring_okv.soon Unix and Unix-like systems orkeyring_okv.dllon Windows).有关
InnoDB表空间加密的信息,请参阅 第 17.13 节,“InnoDB 静态数据加密”。有关插件加载的一般信息,请参阅 第 7.6.1 节,“安装和卸载插件”。For information aboutInnoDBtablespace 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!
命令行格式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 whichlockddoes 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 onlyMyISAMtable access. For more information, including conditions under which it can and cannot be used, see Section 10.11.5, “External Locking”.命令行格式Command-Line Format --flush[={OFF|ON}]系统变量System Variable flush范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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--flushis specified, the value offlush_timedoes not matter and changes toflush_timehave no effect on flush behavior.命令行格式Command-Line Format --gdb[={OFF|ON}]类型Type 布尔Boolean 默认值Default Value OFFOFF为
SIGINT安装中断处理程序(需要用^C停止 mysqld 以设置断点),并禁用堆栈跟踪和核心文件处理。参见 第 7.9.1.4 节,“在 gdb 下调试 mysqld”。Install an interrupt handler forSIGINT(needed to stop mysqld with^Cto 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 theRESTARTstatement: 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--gdbsuppresses forking. For a server started with this option,RESTARTsimply exits and does not restart.在非调试设置中,可以使用
--no-monitor来抑制监视器进程的分叉。In non-debug settings,--no-monitormay 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 themysqlsystem 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-insecureinstead 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 theinit_filesystem variable. For more information, see the description of that variable. In addition, thedisabled_storage_enginessystem variable has no effect.当与
--initialize一起使用时,--ndbcluster选项将被忽略。The--ndbclusteroption is ignored when used together with--initialize.--initialize与--bootstrap和--daemonize互斥。--initializeis mutually exclusive with--bootstrapand--daemonize.
前面列表中的项目在使用
--initialize-insecure选项初始化服务器时也适用。The items in the preceding list also apply when initializing the server using the--initialize-insecureoption.命令行格式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 themysqlsystem 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 MySQLrootuser 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 theInnoDBstorage engine. TheInnoDBoptions 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 isMySQLif noservice_namevalue 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-fileand--installoptions,--installmust 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 isMySQLif noservice_namevalue 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-fileand--install-manualoptions,--install-manualmust be first.命令行格式Command-Line Format --large-pages[={OFF|ON}]系统变量System Variable large_pages范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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-pagesoption.--large-pages默认情况下是禁用的。--large-pagesis disabled by default.命令行格式Command-Line Format --lc-messages=name系统变量System Variable lc_messages范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value en_US用于错误消息的区域设置。默认值为
en_US。服务器将参数转换为语言名称,并将其与--lc-messages-dir的值结合,以生成错误消息文件的位置。参见 第 12.12 节,“设置错误消息语言”。The locale to use for error messages. The default isen_US. The server converts the argument to a language name and combines it with the value of--lc-messages-dirto produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.命令行格式Command-Line Format --lc-messages-dir=dir_name系统变量System Variable lc_messages_dir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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-messagesto produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.命令行格式Command-Line Format --local-service(仅限 Windows)在服务名称之后使用
--local-service选项会使服务器以拥有有限系统权限的LocalServiceWindows 账户运行。如果在服务名称之后同时提供--defaults-file和--local-service,它们的顺序可以任意。参见 第 2.3.3.8 节,“将 MySQL 作为 Windows 服务启动”。(Windows only) A--local-serviceoption following the service name causes the server to run using theLocalServiceWindows account that has limited system privileges. If both--defaults-fileand--local-serviceare 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_VARHint 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 系统上,默认错误日志目标是数据目录中的名为
的文件。在 Windows 上,默认目标相同,除非指定了host_name.err--pid-file选项。在这种情况下,文件名为 PID 文件的基本名,后缀为.err,位于数据目录中。If the option names no file, the default error log destination on Unix and Unix-like systems is a file namedin the data directory. The default destination on Windows is the same, unless thehost_name.err--pid-fileoption is specified. In that case, the file name is the PID file base name with a suffix of.errin the data directory.如果选项指定了一个文件,默认的目标就是该文件(如果文件名没有后缀,则会添加一个
.err后缀),文件位于数据目录下,除非提供了绝对路径来指定不同的位置。If the option names a file, the default destination is that file (with an.errsuffix 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,--consoletakes precedence over--log-errorif 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 allMyISAMchanges to this file (used only when debuggingMyISAM).命令行格式Command-Line Format --log-raw[={OFF|ON}]--log-raw[={OFF|ON}]系统变量System Variable log_raw范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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-rawoption. 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-rawoption affects statement logging as follows:更多信息,请参见 第 8.1.2.3 节,“密码与日志记录”。For more information, see Section 8.1.2.3, “Passwords and Logging”.
命令行格式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 istc.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.
命令行格式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()(从而支持此选项)来判断:--memlockworks on systems that support themlockall()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 notmlockall()(and thus this option) is supported by checking to see whether or not it is defined in the systemmman.hfile, like this:$>
grep mlockall /usr/include/sys/mman.h如果支持
mlockall(),你应该在前一个命令的输出中看到如下类似内容:Ifmlockall()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 asroot, 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 asrootby changing thelimits.conffile. 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 themlockall()system call; if you do so, mysqld is very likely to exit as soon as you try to start it.命令行格式Command-Line Format --myisam-block-size=#类型Type 整数Integer 默认值Default Value 1024最小值Minimum Value 1024最大值Maximum Value 16384用于
MyISAM索引页的块大小。The block size to be used forMyISAMindex pages.命令行格式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 themysql_native_passwordauthentication 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来防止读取它们。如果使用此选项,它必须是命令行上的第一个选项。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. 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”.
命令行格式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 theRESTARTstatement: Forking enables one process to act as a monitor to the other, which acts as the server. For a server started with this option,RESTARTsimply 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”.
命令行格式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-loadoptions are given, only the last one applies. Additional plugins to load may be specified using--plugin-load-addoptions.该选项值是一个由分号分隔的
plugin_library和name=plugin_library值组成的列表。每个plugin_library都是包含插件代码的库文件的名称,每个name是要加载的插件的名称。如果插件库的名称没有前置插件名称,服务器将加载库中的所有插件。如果有前置插件名称,服务器只加载库中命名的插件。服务器在由plugin_dir系统变量指定的目录中查找插件库文件。The option value is a semicolon-separated list ofplugin_libraryandname=plugin_libraryvalues. Eachplugin_libraryis the name of a library file that contains plugin code, and eachnameis 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 theplugin_dirsystem variable.例如,如果名为
myplug1和myplug2的插件包含在插件库文件myplug1.so和myplug2.so中,请使用此选项执行早期插件加载:For example, if plugins namedmyplug1andmyplug2are contained in the plugin library filesmyplug1.soandmyplug2.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-loadis used again. This is in contrast toINSTALL PLUGIN, which adds an entry to themysql.pluginstable 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 themysql.pluginssystem table. If the server is started with the--skip-grant-tablesoption, plugins registered in themysql.pluginstable are not loaded and are unavailable.--plugin-loadenables plugins to be loaded even when--skip-grant-tablesis given.--plugin-loadalso 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 ofSHOW PLUGINSprovides information about loaded plugins. More detailed information can be found in the Information SchemaPLUGINStable. 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”.
命令行格式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-loadoption.--plugin-load-addadds 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-addcan be used to avoid specifying a large set of plugins as a single long unwieldy--plugin-loadargument.--plugin-load-add可以在没有--plugin-load的情况下使用,但任何出现在--plugin-load之前的--plugin-load-add实例都不会生效,因为--plugin-load会重置要加载的插件集合。换句话说,这些选项:--plugin-load-addcan be given in the absence of--plugin-load, but any instance of--plugin-load-addthat appears before--plugin-loadhas no effect because--plugin-loadresets 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 ofSHOW PLUGINSprovides information about loaded plugins. More detailed information can be found in the Information SchemaPLUGINStable. 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前缀来指定它们的选项。因此,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--pluginprefix. Thus, the--innodb-file-per-tableoption forInnoDBcan 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--skipprefix and other alternative formats are supported as well (see Section 6.2.2.4, “Program Option Modifiers”). For example,--skip-plugin-innodb-file-per-tabledisablesinnodb-file-per-table.--plugin前缀的原理是,当插件选项与内置服务器选项名称冲突时,可以明确指定插件选项。例如,如果插件开发者将插件命名为 “sql” 并实现一个 “mode” 选项,则该选项名称可能为--sql-mode,这将与同名的内置选项冲突。在这种情况下,对冲突名称的引用将优先解析为内置选项。为了避免歧义,用户可以将插件选项指定为--plugin-sql-mode。建议为插件选项使用--plugin前缀,以避免任何歧义问题。The rationale for the--pluginprefix 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--pluginprefix for plugin options is recommended to avoid any question of ambiguity.--port=,port_num-Pport_num命令行格式Command-Line Format --port=port_num--port=port_num系统变量System Variable portport范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 therootoperating system user. Setting this option to 0 causes the default value to be used.命令行格式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.
打印程序名称及其从选项文件获取的所有选项。密码值将被屏蔽。如果使用此选项,它必须是命令行上的第一个选项,除非它紧接在
--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-fileor--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”.
命令行格式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 isMySQLif noservice_namevalue is given. For more information, see Section 2.3.3.8, “Starting MySQL as a Windows Service”.命令行格式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 theGRANTstatement unless the user has theINSERTprivilege for themysql.usersystem 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 theGRANTstatement to give privileges to other users.命令行格式Command-Line Format --skip-grant-tables[={OFF|ON}]类型Type 布尔Boolean 默认值Default Value OFFOFF此选项会影响服务器启动顺序:This option affects the server startup sequence:
--skip-grant-tables会导致服务器不读取mysql系统模式中的授权表,因此以完全不使用权限系统的方式启动。这使得任何可以访问服务器的人 可以不受限制地访问所有数据库。--skip-grant-tablescauses the server not to read the grant tables in themysqlsystem schema, and thus to start without using the privilege system at all. This gives anyone with access to the server unrestricted access to all databases.由于使用
--skip-grant-tables启动服务器会禁用身份验证检查,因此在这种情况下服务器还会通过启用skip_networking来禁用远程连接。Because starting the server with--skip-grant-tablesdisables authentication checks, the server also disables remote connections in that case by enablingskip_networking.要使使用
--skip-grant-tables启动的服务器在运行时加载授权表,需要执行权限刷新的操作,可以通过以下方式完成:To cause a server started with--skip-grant-tablesto load the grant tables at runtime, perform a privilege-flushing operation, which can be done in these ways:连接到服务器后,执行 MySQL
FLUSH PRIVILEGES语句。Issue a MySQLFLUSH PRIVILEGESstatement after connecting to the server.从命令行执行 mysqladmin flush-privileges 或 mysqladmin reload 命令。Execute a mysqladmin flush-privileges or mysqladmin reload command from the command line.
权限刷新也可能隐式地由于启动后执行的其他操作而发生,从而导致服务器开始使用权限表。例如,如果服务器在启动序列中执行升级,它会刷新权限。Privilege flushing might also occur implicitly as a result of other actions performed after startup, thus causing the server to start using the grant tables. For example, the server flushes the privileges if it performs an upgrade during the startup sequence.
--skip-grant-tables会禁用失败登录跟踪和临时账户锁定,因为这些功能依赖授权表。请参见 第 8.2.15 节,“密码管理”。--skip-grant-tablesdisables failed-login tracking and temporary account locking because those capabilities depend on the grant tables. See Section 8.2.15, “Password Management”.--skip-grant-tables会导致服务器不加载数据字典或mysql系统模式中注册的某些其他对象:--skip-grant-tablescauses the server not to load certain other objects registered in the data dictionary or themysqlsystem schema:使用
CREATE EVENT安装并在events数据字典表中注册的计划事件。Scheduled events installed usingCREATE EVENTand registered in theeventsdata dictionary table.使用
INSTALL PLUGIN安装并注册在mysql.plugin系统表中的插件。Plugins installed usingINSTALL PLUGINand registered in themysql.pluginsystem table.为了在使用
--skip-grant-tables时仍然加载插件,可使用--plugin-load或--plugin-load-add选项。To cause plugins to be loaded even when using--skip-grant-tables, use the--plugin-loador--plugin-load-addoption.使用
CREATE FUNCTION安装并注册在mysql.func系统表中的可加载函数。Loadable functions installed usingCREATE FUNCTIONand registered in themysql.funcsystem table.
--skip-grant-tables不会 阻止组件在启动时加载。--skip-grant-tablesdoes not suppress loading during startup of components.--skip-grant-tables会导致disabled_storage_engines系统变量无效。--skip-grant-tablescauses thedisabled_storage_enginessystem variable to have no effect.
命令行格式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 causesOPTIMIZE TABLEto be mapped toALTER TABLEfor storage engines for whichOPTIMIZE TABLEis not supported.此选项已被弃用,并可能在未来版本中移除。This option is deprecated, and subject to removal in a future release.
命令行格式Command-Line Format --skip-show-database系统变量System Variable skip_show_database范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF此选项设置
skip_show_database系统变量,该变量控制谁被允许使用SHOW DATABASES语句。参见 第 7.1.8 节,“服务器系统变量”。This option sets theskip_show_databasesystem variable that controls who is permitted to use theSHOW DATABASESstatement. See Section 7.1.8, “Server System Variables”.命令行格式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.
命令行格式Command-Line Format --socket={file_name|pipe_name}--socket={file_name|pipe_name}系统变量System Variable socket范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 isMySQL(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_VARHint 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_DATESANSI_QUOTESANSI_QUOTESERROR_FOR_DIVISION_BY_ZEROERROR_FOR_DIVISION_BY_ZEROHIGH_NOT_PRECEDENCEHIGH_NOT_PRECEDENCEIGNORE_SPACEIGNORE_SPACENO_AUTO_VALUE_ON_ZERONO_AUTO_VALUE_ON_ZERONO_BACKSLASH_ESCAPESNO_BACKSLASH_ESCAPESNO_DIR_IN_CREATENO_DIR_IN_CREATENO_ENGINE_SUBSTITUTIONNO_ENGINE_SUBSTITUTIONNO_UNSIGNED_SUBTRACTIONNO_UNSIGNED_SUBTRACTIONNO_ZERO_DATENO_ZERO_DATENO_ZERO_IN_DATENO_ZERO_IN_DATEONLY_FULL_GROUP_BYONLY_FULL_GROUP_BYPAD_CHAR_TO_FULL_LENGTHPAD_CHAR_TO_FULL_LENGTHPIPES_AS_CONCATPIPES_AS_CONCATREAL_AS_FLOATREAL_AS_FLOATSTRICT_ALL_TABLESSTRICT_ALL_TABLESSTRICT_TRANS_TABLESSTRICT_TRANS_TABLESTIME_TRUNCATE_FRACTIONALTIME_TRUNCATE_FRACTIONAL设置 SQL 模式。参见 第 7.1.11 节,“服务器 SQL 模式”。Set the SQL mode. See Section 7.1.11, “Server SQL Modes”.
NoteMySQL 安装程序可能会在安装过程中配置 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.
命令行格式Command-Line Format --standalone特定平台Platform Specific 窗口Windows 仅适用于 Windows;指示 MySQL 服务器不要以服务方式运行。Available on Windows only; instructs the MySQL server not to run as a service.
命令行格式Command-Line Format --super-large-pages[={OFF|ON}]--super-large-pages[={OFF|ON}]特定平台Platform Specific 太阳神Solaris 类型Type 布尔Boolean 默认值Default Value OFFOFFStandard 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-pagesor--skip-super-large-pagesoption.--symbolic-links,--skip-symbolic-links命令行格式Command-Line Format --symbolic-links[={OFF|ON}]已弃用Deprecated 是Yes 类型Type 布尔Boolean 默认值Default Value OFFOFFEnable or disable symbolic link support. On Unix, enabling symbolic links means that you can link a
MyISAMindex file or data file to another directory with theINDEX DIRECTORY或者DATA DIRECTORYoption of theCREATE TABLEstatement. 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 aMyISAMindex file or data file to another directory with theINDEX DIRECTORYorDATA DIRECTORYoption of theCREATE TABLEstatement. 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-linksoption 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 relatedhave_symlinksystem variable also is deprecated; expect it to be removed in a future version of MySQL.此选项在 Windows 上没有意义。This option has no meaning on Windows.
命令行格式Command-Line Format --sysdate-is-now[={OFF|ON}]--sysdate-is-now[={OFF|ON}]类型Type 布尔Boolean 默认值Default Value OFFOFFSYSDATE()默认返回其执行时的时间,而不是其所在语句开始执行的时间。这与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 ofNOW(). This option causesSYSDATE()to be a synonym forNOW(). For information about the implications for binary logging and replication, see the description forSYSDATE()in Section 14.7, “Date and Time Functions” and forSET TIMESTAMPin 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 OFFOFFCOMMITCOMMITROLLBACKROLLBACK决定使用手动启发式恢复。The decision to use in a manual heuristic recovery.
如果指定了
--tc-heuristic-recover选项,无论手动启发式恢复是否成功,服务器都会退出。If a--tc-heuristic-recoveroption 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, theROLLBACKoption 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.
命令行格式Command-Line Format --transaction-isolation=name系统变量System Variable transaction_isolation范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value REPEATABLE-READREPEATABLE-READ有效值Valid Values READ-UNCOMMITTEDREAD-UNCOMMITTEDREAD-COMMITTEDREAD-COMMITTEDREPEATABLE-READREPEATABLE-READSERIALIZABLESERIALIZABLE设置默认事务隔离级别。
level值可以是READ-UNCOMMITTED、READ-COMMITTED、REPEATABLE-READ或SERIALIZABLE。参见 第 15.3.7 节,“SET TRANSACTION 语句”。Sets the default transaction isolation level. Thelevelvalue can beREAD-UNCOMMITTED,READ-COMMITTED,REPEATABLE-READ, orSERIALIZABLE. See Section 15.3.7, “SET TRANSACTION Statement”.默认的事务隔离级别也可以在运行时使用
SET TRANSACTION语句设置,或者通过设置transaction_isolation系统变量来设置。The default transaction isolation level can also be set at runtime using theSET TRANSACTIONstatement or by setting thetransaction_isolationsystem variable.命令行格式Command-Line Format --transaction-read-only[={OFF|ON}]系统变量System Variable transaction_read_only范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theSET TRANSACTIONstatement or set thetransaction_read_onlysystem variable. See Section 15.3.7, “SET TRANSACTION Statement”.--tmpdir=dir_name,-t dir_name--tmpdir=,dir_name-tdir_name命令行格式Command-Line Format --tmpdir=dir_name--tmpdir=dir_name系统变量System Variable tmpdir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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/tmpdirectory 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语句的临时文件会存储在此目录中,因此如果使用永久位置,它们可以在机器重启后保留,尽管如果临时文件已被删除,重启后复制现在也可以继续进行。--tmpdircan 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 thereplica_load_tmpdirsystem variable. For a replica, the temporary files used to replicateLOAD DATAstatements 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 AUTOAUTONONENONEMINIMALMINIMALFORCEFORCE此选项控制服务器是否以及如何在启动时执行自动升级。自动升级包括两个步骤: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 themysqlschema. 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 andINFORMATION_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 themysqlschema (the remaining non-data dictionary tables).sys模式。Thesysschema.用户模式。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--upgradeoption 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--upgradeis 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 theINFORMATION_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 theINFORMATION_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 的操作。例如,你可能认为某个系统表缺失或已损坏,并希望强制进行修复。FORCEis 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 nameuser_nameor the numeric user IDuser_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 asroot. The server changes its user ID during its startup sequence, causing it to run as that particular user rather than asroot. 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=rootoption to amy.cnffile (thus causing the server to run asroot), mysqld uses only the first--useroption specified and produces a warning if there are multiple--useroptions. Options in/etc/my.cnfand$MYSQL_HOME/my.cnfare processed before command-line options, so it is recommended that you put a--useroption in/etc/my.cnfand specify a value other thanroot. The option in/etc/my.cnfis found before any other--useroptions, which ensures that the server runs as a user other thanroot, and that a warning results if any other--useroption is found.命令行格式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 thelog_error_verbosityvalue, 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 thesha256_password(deprecated) orcaching_sha2_passwordauthentication 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-pluginsslows down server initialization andFLUSH PRIVILEGES. If you do not require the additional checking, you can disable this option at startup to avoid the performance decrement.使用此选项与
--help选项一起以获取详细帮助。Use this option with the--helpoption for detailed help.--version,-V显示版本信息并退出。Display version information and exit.