4.2.2.1 Using Options on the Command Line使用命令行上的选项

Program options specified on the command line follow these rules:命令行上指定的程序选项遵循以下规则:

Option values that contain spaces must be quoted when given on the command line. 在命令行中给出包含空格的选项值时,必须将其引用。For example, the --execute (or -e) option can be used with mysql to pass one or more semicolon-separated SQL statements to the server. 例如,--execute(或-e)选项可以与mysql一起使用,将一个或多个分号分隔的SQL语句传递给服务器。When this option is used, mysql executes the statements in the option value and exits. 使用此选项时,mysql执行选项值中的语句并退出。The statements must be enclosed by quotation marks. 这些陈述必须用引号括起来。For example:例如:

shell> mysql -u root -p -e "SELECT VERSION();SELECT NOW()"
Enter password: ******
+------------+
| VERSION()  |
+------------+
| 8.0.19     |
+------------+
+---------------------+
| NOW()               |
+---------------------+
| 2019-09-03 10:36:48 |
+---------------------+
shell>
Note注意

The long form (--execute) is followed by an equal sign (=).长格式(--execute)后面跟一个等号(=)。

To use quoted values within a statement, you must either escape the inner quotation marks, or use a different type of quotation marks within the statement from those used to quote the statement itself. 要在语句中使用引号,必须转义内部引号,或在语句中使用与用于引用语句本身的引号不同的引号。The capabilities of your command processor dictate your choices for whether you can use single or double quotation marks and the syntax for escaping quote characters. 命令处理器的功能决定了您可以选择使用单引号还是双引号,以及转义引号字符的语法。For example, if your command processor supports quoting with single or double quotation marks, you can use double quotation marks around the statement, and single quotation marks for any quoted values within the statement.例如,如果命令处理器支持使用单引号或双引号进行引用,则可以在语句周围使用双引号,并对语句中的任何引用值使用单引号。