4.2.2 Specifying Program Options指定程序选项

4.2.2.1 Using Options on the Command Line使用命令行上的选项
4.2.2.2 Using Option Files使用选项文件
4.2.2.3 Command-Line Options that Affect Option-File Handling影响选项文件处理的命令行选项
4.2.2.4 Program Option Modifiers程序选项修饰符
4.2.2.5 Using Options to Set Program Variables使用选项设置程序变量
4.2.2.6 Option Defaults, Options Expecting Values, and the = Sign选项默认值、选项期望值和=符号

There are several ways to specify options for MySQL programs:有几种方法可以指定MySQL程序的选项:

Options are processed in order, so if an option is specified multiple times, the last occurrence takes precedence. 选项是按顺序处理的,因此如果多次指定某个选项,则最后一次出现的选项优先。The following command causes mysql to connect to the server running on localhost:以下命令使mysql连接到在localhost上运行的服务器:

mysql -h example.com -h localhost

There is one exception: For mysqld, the first instance of the --user option is used as a security precaution, to prevent a user specified in an option file from being overridden on the command line.有一个例外:对于mysqld--user选项的第一个实例用作安全预防措施,以防止在选项文件中指定的用户在命令行上被重写。

If conflicting or related options are given, later options take precedence over earlier options. 如果给出了冲突或相关的选项,则后面的选项优先于前面的选项。The following command runs mysql in no column names mode:以下命令以“无列名”模式运行mysql

mysql --column-names --skip-column-names

MySQL programs determine which options are given first by examining environment variables, then by processing option files, and then by checking the command line. MySQL程序首先通过检查环境变量,然后通过处理选项文件,然后通过检查命令行来确定给出了哪些选项。Because later options take precedence over earlier ones, the processing order means that environment variables have the lowest precedence and command-line options the highest.由于后面的选项优先于前面的选项,因此处理顺序意味着环境变量的优先级最低,命令行选项的优先级最高。

For the server, one exception applies: The mysqld-auto.cnf option file in the data directory is processed last, so it takes precedence even over command-line options.对于服务器,有一个例外:数据目录中的mysqld-auto.cnf选项文件是最后处理的,因此它甚至优先于命令行选项。

You can take advantage of the way that MySQL programs process options by specifying default option values for a program in an option file. 通过在选项文件中为程序指定默认选项值,可以利用MySQL程序处理选项的方式。That enables you to avoid typing them each time you run the program while enabling you to override the defaults if necessary by using command-line options.这使您能够避免在每次运行程序时键入它们,同时允许您在必要时使用命令行选项覆盖默认值。

4.2.2.1 Using Options on the Command Line
4.2.2.2 Using Option Files
4.2.2.3 Command-Line Options that Affect Option-File Handling
4.2.2.4 Program Option Modifiers
4.2.2.5 Using Options to Set Program Variables
4.2.2.6 Option Defaults, Options Expecting Values, and the = Sign