5.1.7 Server Command Options服务器命令选项

When you start the mysqld server, you can specify program options using any of the methods described in Section 4.2.2, “Specifying Program Options”. 启动mysqld服务器时,可以使用第4.2.2节,“指定程序选项”中描述的任何方法指定程序选项。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 4.2.2.2, “Using Option Files”. 请参阅第4.2.2.2节,“使用选项文件”That section also describes option file format and syntax.该部分还介绍了选项文件格式和语法。

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

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

mysqld --help

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

mysqld --verbose --help

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. 可以使用SHOW VARIABLES语句在运行时显示这些变量。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.前面的mysqld命令显示的某些项目不会出现在SHOW VARIABLES输出中;这是因为它们只是选项,而不是系统变量。

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

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.例如,如果将值0指定给最小值为1024的选项,则服务器会将该值设置为1024。

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

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. 假设数据目录为/var/mysql/dataIf a file-valued option is given as a relative path name, it is located under /var/mysql/data. 如果文件值选项作为相对路径名给出,则它位于/var/mysql/data下。If the value is an absolute path name, its location is as given by the path name.如果该值是绝对路径名,则其位置由路径名给定。

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. 要为服务器系统变量赋值,请使用形式为--var_name=value的选项。For example, --sort_buffer_size=384M sets the sort_buffer_size variable to a value of 384MB.例如,--sort_buffer_size=384Msort_buffer_size变量的值设置为384MB。

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.当您为变量赋值时,MySQL可能会自动更正该值,使其保持在给定的范围内,或者在只允许某些值的情况下将该值调整为最接近的允许值。

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语句设置系统变量的最大值,请在服务器启动时,使用以下形式的选项指定此最大值--max-var_name=value

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

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