Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.1Mb
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

4.5.1.1 mysql Client Options

mysql supports the following options, which can be specified on the command line or in the[mysql] and[client] groups of an option file. For information about option files used by MySQL programs, seeSection 4.2.2.2, “Using Option Files”.

Table 4.13 mysql Client Options

Option NameDescriptionIntroducedDeprecated
--auto-rehashEnable automatic rehashing
--auto-vertical-outputEnable automatic vertical result set display
--batchDo not use history file
--binary-as-hexDisplay binary values in hexadecimal notation5.7.19
--binary-modeDisable \r\n - to - \n translation and treatment of \0 as end-of-query
--bind-addressUse specified network interface to connect to MySQL Server
--character-sets-dirDirectory where character sets are installed
--column-namesWrite column names in results
--column-type-infoDisplay result set metadata
--commandsEnable or disable processing of local mysql client commands5.7.44-ndb-7.6.35
--commentsWhether to retain or strip comments in statements sent to the server
--compressCompress all information sent between client and server
--connect-expired-passwordIndicate to server that client can handle expired-password sandbox mode
--connect-timeoutNumber of seconds before connection timeout
--databaseThe database to use
--debugWrite debugging log; supported only if MySQL was built with debugging support
--debug-checkPrint debugging information when program exits
--debug-infoPrint debugging information, memory, and CPU statistics when program exits
--default-authAuthentication plugin to use
--default-character-setSpecify default character set
--defaults-extra-fileRead named option file in addition to usual option files
--defaults-fileRead only named option file
--defaults-group-suffixOption group suffix value
--delimiterSet the statement delimiter
--enable-cleartext-pluginEnable cleartext authentication plugin
--executeExecute the statement and quit
--forceContinue even if an SQL error occurs
--get-server-public-keyRequest RSA public key from server5.7.23
--helpDisplay help message and exit
--histignorePatterns specifying which statements to ignore for logging
--hostHost on which MySQL server is located
--htmlProduce HTML output
--ignore-spacesIgnore spaces after function names
--init-commandSQL statement to execute after connecting
--line-numbersWrite line numbers for errors
--local-infileEnable or disable for LOCAL capability for LOAD DATA
--login-pathRead login path options from .mylogin.cnf
--max-allowed-packetMaximum packet length to send to or receive from server
--max-join-sizeThe automatic limit for rows in a join when using --safe-updates
--named-commandsEnable named mysql commands
--net-buffer-lengthBuffer size for TCP/IP and socket communication
--no-auto-rehashDisable automatic rehashing
--no-beepDo not beep when errors occur
--no-defaultsRead no option files
--one-databaseIgnore statements except those for the default database named on the command line
--pagerUse the given command for paging query output
--passwordPassword to use when connecting to server
--pipeConnect to server using named pipe (Windows only)
--plugin-dirDirectory where plugins are installed
--portTCP/IP port number for connection
--print-defaultsPrint default options
--promptSet the prompt to the specified format
--protocolTransport protocol to use
--quickDo not cache each query result
--rawWrite column values without escape conversion
--reconnectIf the connection to the server is lost, automatically try to reconnect
--safe-updates,--i-am-a-dummyAllow only UPDATE and DELETE statements that specify key values
--secure-authDo not send passwords to server in old (pre-4.1) formatYes
--select-limitThe automatic limit for SELECT statements when using --safe-updates
--server-public-key-pathPath name to file containing RSA public key
--shared-memory-base-nameShared-memory name for shared-memory connections (Windows only)
--show-warningsShow warnings after each statement if there are any
--sigint-ignoreIgnore SIGINT signals (typically the result of typing Control+C)
--silentSilent mode
--skip-auto-rehashDisable automatic rehashing
--skip-column-namesDo not write column names in results
--skip-line-numbersSkip line numbers for errors
--skip-named-commandsDisable named mysql commands
--skip-pagerDisable paging
--skip-reconnectDisable reconnecting
--socketUnix socket file or Windows named pipe to use
--sslEnable connection encryption
--ssl-caFile that contains list of trusted SSL Certificate Authorities
--ssl-capathDirectory that contains trusted SSL Certificate Authority certificate files
--ssl-certFile that contains X.509 certificate
--ssl-cipherPermissible ciphers for connection encryption
--ssl-crlFile that contains certificate revocation lists
--ssl-crlpathDirectory that contains certificate revocation-list files
--ssl-keyFile that contains X.509 key
--ssl-modeDesired security state of connection to server5.7.11
--ssl-verify-server-certVerify host name against server certificate Common Name identity
--syslogLog interactive statements to syslog
--tableDisplay output in tabular format
--teeAppend a copy of output to named file
--tls-versionPermissible TLS protocols for encrypted connections5.7.10
--unbufferedFlush the buffer after each query
--userMySQL user name to use when connecting to server
--verboseVerbose mode
--versionDisplay version information and exit
--verticalPrint query output rows vertically (one line per column value)
--waitIf the connection cannot be established, wait and retry instead of aborting
--xmlProduce XML output

  • --help,-?

    Command-Line Format--help

    Display a help message and exit.

  • --auto-rehash

    Command-Line Format--auto-rehash
    Disabled byskip-auto-rehash

    Enable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use--disable-auto-rehash to disable rehashing. That causesmysql to start faster, but you must issue therehash command or its\# shortcut if you want to use name completion.

    To complete a name, enter the first part and press Tab. If the name is unambiguous,mysql completes it. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far. Completion does not occur if there is no default database.

    Note

    This feature requires a MySQL client that is compiled with thereadline library. Typically, thereadline library is not available on Windows.

  • --auto-vertical-output

    Command-Line Format--auto-vertical-output

    Cause result sets to be displayed vertically if they are too wide for the current window, and using normal tabular format otherwise. (This applies to statements terminated by; or\G.)

  • --batch,-B

    Command-Line Format--batch

    Print results using tab as the column separator, with each row on a new line. With this option,mysql does not use the history file.

    Batch mode results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the--raw option.

  • --binary-as-hex

    Command-Line Format--binary-as-hex
    Introduced5.7.19
    TypeBoolean
    Default ValueFALSE

    When this option is given,mysql displays binary data using hexadecimal notation (0xvalue). This occurs whether the overall output display format is tabular, vertical, HTML, or XML.

    --binary-as-hex when enabled affects display of all binary strings, including those returned by functions such asCHAR() andUNHEX(). The following example demonstrates this using the ASCII code forA (65 decimal, 41 hexadecimal):

    • --binary-as-hex disabled:

      mysql> SELECT CHAR(0x41), UNHEX('41');+------------+-------------+| CHAR(0x41) | UNHEX('41') |+------------+-------------+| A          | A           |+------------+-------------+
    • --binary-as-hex enabled:

      mysql> SELECT CHAR(0x41), UNHEX('41');+------------------------+--------------------------+| CHAR(0x41)             | UNHEX('41')              |+------------------------+--------------------------+| 0x41                   | 0x41                     |+------------------------+--------------------------+

    To write a binary string expression so that it displays as a character string regardless of whether--binary-as-hex is enabled, use these techniques:

    • TheCHAR() function has aUSINGcharset clause:

      mysql> SELECT CHAR(0x41 USING utf8mb4);+--------------------------+| CHAR(0x41 USING utf8mb4) |+--------------------------+| A                        |+--------------------------+
    • More generally, useCONVERT() to convert an expression to a given character set:

      mysql> SELECT CONVERT(UNHEX('41') USING utf8mb4);+------------------------------------+| CONVERT(UNHEX('41') USING utf8mb4) |+------------------------------------+| A                                  |+------------------------------------+

    This option was added in MySQL 5.7.19.

  • --binary-mode

    Command-Line Format--binary-mode

    This option helps when processingmysqlbinlog output that may containBLOB values. By default,mysql translates\r\n in statement strings to\n and interprets\0 as the statement terminator.--binary-mode disables both features. It also disables allmysql commands exceptcharset anddelimiter in noninteractive mode (for input piped tomysql or loaded using thesource command).

    (NDB Cluster 7.6.35 and later:)--binary-mode, when enabled, causes the server to disregard any setting for--commands .

  • --bind-address=ip_address

    Command-Line Format--bind-address=ip_address

    On a computer having multiple network interfaces, use this option to select which interface to use for connecting to the MySQL server.

  • --character-sets-dir=dir_name

    Command-Line Format--character-sets-dir=dir_name
    TypeDirectory name

    The directory where character sets are installed. SeeSection 10.15, “Character Set Configuration”.

  • --column-names

    Command-Line Format--column-names

    Write column names in results.

  • --column-type-info

    Command-Line Format--column-type-info

    Display result set metadata. This information corresponds to the contents of C APIMYSQL_FIELD data structures. SeeC API Basic Data Structures.

  • --commands

    Command-Line Format--commands
    Introduced5.7.44-ndb-7.6.35

    Whether to enable or disable processing of localmysql client commands. Setting this option toFALSE disables such processing, and has the effects listed here:

    • The followingmysql client commands are disabled:

      • charset (/C remains enabled)

      • clear

      • connect

      • edit

      • ego

      • exit

      • go

      • help

      • nopager

      • notee

      • nowarning

      • pager

      • print

      • prompt

      • query_attributes

      • quit

      • rehash

      • resetconnection

      • ssl_session_data_print

      • source

      • status

      • system

      • tee

      • \u (use is passed to the server)

      • warnings

    • The\C anddelimiter commands remain enabled.

    • The--system-command option is ignored, and has no effect.

    This option has no effect when--binary-mode is enabled.

    When--commands is enabled, it is possible to disable (only) the system command using the--system-command option.

    This option was added in NDB Cluster 7.6.35.

  • --comments,-c

    Command-Line Format--comments
    TypeBoolean
    Default ValueFALSE

    Whether to strip or preserve comments in statements sent to the server. The default is--skip-comments (strip comments), enable with--comments (preserve comments).

    Note

    In MySQL 5.7, themysql client always passes optimizer hints to the server, regardless of whether this option is given. To ensure that optimizer hints are not stripped if you are using an older version of themysql client with a version of the server that understands optimizer hints, invokemysql with the--comments option.

    Comment stripping is deprecated as of MySQL 5.7.20. You should expect this feature and the options to control it to be removed in a future MySQL release.

  • --compress,-C

    Command-Line Format--compress[={OFF|ON}]
    TypeBoolean
    Default ValueOFF

    Compress all information sent between the client and the server if possible. SeeSection 4.2.6, “Connection Compression Control”.

  • --connect-expired-password

    Command-Line Format--connect-expired-password

    Indicate to the server that the client can handle sandbox mode if the account used to connect has an expired password. This can be useful for noninteractive invocations ofmysql because normally the server disconnects noninteractive clients that attempt to connect using an account with an expired password. (SeeSection 6.2.12, “Server Handling of Expired Passwords”.)

  • --connect-timeout=value

    Command-Line Format--connect-timeout=value
    TypeNumeric
    Default Value0

    The number of seconds before connection timeout. (Default value is0.)

  • --database=db_name,-Ddb_name

    Command-Line Format--database=dbname
    TypeString

    The database to use. This is useful primarily in an option file.

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

    Command-Line Format--debug[=debug_options]
    TypeString
    Default Valued:t:o,/tmp/mysql.trace

    Write a debugging log. A typicaldebug_options string isd:t:o,file_name. The default isd:t:o,/tmp/mysql.trace.

    This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle arenot built using this option.

  • --debug-check

    Command-Line Format--debug-check
    TypeBoolean
    Default ValueFALSE

    Print some debugging information when the program exits.

    This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle arenot built using this option.

  • --debug-info,-T

    Command-Line Format--debug-info
    TypeBoolean
    Default ValueFALSE

    Print debugging information and memory and CPU usage statistics when the program exits.

    This option is available only if MySQL was built usingWITH_DEBUG. MySQL release binaries provided by Oracle arenot built using this option.

  • --default-auth=plugin

    Command-Line Format--default-auth=plugin
    TypeString

    A hint about which client-side authentication plugin to use. SeeSection 6.2.13, “Pluggable Authentication”.

  • --default-character-set=charset_name

    Command-Line Format--default-character-set=charset_name
    TypeString

    Usecharset_name as the default character set for the client and connection.

    This option can be useful if the operating system uses one character set and themysql client by default uses another. In this case, output may be formatted incorrectly. You can usually fix such issues by using this option to force the client to use the system character set instead.

    For more information, seeSection 10.4, “Connection Character Sets and Collations”, andSection 10.15, “Character Set Configuration”.

  • --defaults-extra-file=file_name

    Command-Line Format--defaults-extra-file=file_name
    TypeFile 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_name is not an absolute path name, it is interpreted relative to the current directory.

    For additional information about this and other option-file options, seeSection 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.

  • --defaults-file=file_name

    Command-Line Format--defaults-file=file_name
    TypeFile name

    Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. Iffile_name is not an absolute path name, it is interpreted relative to the current directory.

    Exception: Even with--defaults-file, client programs read.mylogin.cnf.

    For additional information about this and other option-file options, seeSection 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.

  • --defaults-group-suffix=str

    Command-Line Format--defaults-group-suffix=str
    TypeString

    Read not only the usual option groups, but also groups with the usual names and a suffix ofstr. For example,mysql normally reads the[client] and[mysql] groups. If this option is given as--defaults-group-suffix=_other,mysql also reads the[client_other] and[mysql_other] groups.

    For additional information about this and other option-file options, seeSection 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.

  • --delimiter=str

    Command-Line Format--delimiter=str
    TypeString
    Default Value;

    Set the statement delimiter. The default is the semicolon character (;).

  • --disable-named-commands

    Disable named commands. Use the\* form only, or use named commands only at the beginning of a line ending with a semicolon (;).mysql starts with this optionenabled by default. However, even with this option, long-format commands still work from the first line. SeeSection 4.5.1.2, “mysql Client Commands”.

  • --enable-cleartext-plugin

    Command-Line Format--enable-cleartext-plugin
    TypeBoolean
    Default ValueFALSE

    Enable themysql_clear_password cleartext authentication plugin. (SeeSection 6.4.1.6, “Client-Side Cleartext Pluggable Authentication”.)

  • --execute=statement,-estatement

    Command-Line Format--execute=statement
    TypeString

    Execute the statement and quit. The default output format is like that produced with--batch. SeeSection 4.2.2.1, “Using Options on the Command Line”, for some examples. With this option,mysql does not use the history file.

  • --force,-f

    Command-Line Format--force

    Continue even if an SQL error occurs.

  • --get-server-public-key

    Command-Line Format--get-server-public-key
    Introduced5.7.23
    TypeBoolean

    Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with thecaching_sha2_password authentication plugin. For that plugin, the server does not send the public key unless requested. This option is ignored for accounts that do not authenticate with that plugin. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.

    If--server-public-key-path=file_name is given and specifies a valid public key file, it takes precedence over--get-server-public-key.

    For information about thecaching_sha2_password plugin, seeSection 6.4.1.4, “Caching SHA-2 Pluggable Authentication”.

    The--get-server-public-key option was added in MySQL 5.7.23.

  • --histignore

    Command-Line Format--histignore=pattern_list
    TypeString

    A list of one or more colon-separated patterns specifying statements to ignore for logging purposes. These patterns are added to the default pattern list ("*IDENTIFIED*:*PASSWORD*"). The value specified for this option affects logging of statements written to the history file, and tosyslog if the--syslog option is given. For more information, seeSection 4.5.1.3, “mysql Client Logging”.

  • --host=host_name,-hhost_name

    Command-Line Format--host=host_name
    TypeString
    Default Valuelocalhost

    Connect to the MySQL server on the given host.

  • --html,-H

    Command-Line Format--html

    Produce HTML output.

  • --ignore-spaces,-i

    Command-Line Format--ignore-spaces

    Ignore spaces after function names. The effect of this is described in the discussion for theIGNORE_SPACE SQL mode (seeSection 5.1.10, “Server SQL Modes”).

  • --init-command=str

    Command-Line Format--init-command=str

    SQL statement to execute after connecting to the server. If auto-reconnect is enabled, the statement is executed again after reconnection occurs.

  • --line-numbers

    Command-Line Format--line-numbers
    Disabled byskip-line-numbers

    Write line numbers for errors. Disable this with--skip-line-numbers.

  • --local-infile[={0|1}]

    Command-Line Format--local-infile[={0|1}]
    TypeBoolean
    Default ValueFALSE

    By default,LOCAL capability forLOAD DATA is determined by the default compiled into the MySQL client library. To enable or disableLOCAL data loading explicitly, use the--local-infile option. When given with no value, the option enablesLOCAL data loading. When given as--local-infile=0 or--local-infile=1, the option disables or enablesLOCAL data loading.

    Successful use ofLOCAL load operations withinmysql also requires that the server permits local loading; seeSection 6.1.6, “Security Considerations for LOAD DATA LOCAL”

  • --login-path=name

    Command-Line Format--login-path=name
    TypeString

    Read options from the named login path in the.mylogin.cnf login path file. Alogin path is an option group containing options that specify which MySQL server to connect to and which account to authenticate as. To create or modify a login path file, use themysql_config_editor utility. SeeSection 4.6.6, “mysql_config_editor — MySQL Configuration Utility”.

    For additional information about this and other option-file options, seeSection 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.

  • --max-allowed-packet=value

    Command-Line Format--max-allowed-packet=value
    TypeNumeric
    Default Value16777216

    The maximum size of the buffer for client/server communication. The default is 16MB, the maximum is 1GB.

  • --max-join-size=value

    Command-Line Format--max-join-size=value
    TypeNumeric
    Default Value1000000

    The automatic limit for rows in a join when using--safe-updates. (Default value is 1,000,000.)

  • --named-commands,-G

    Command-Line Format--named-commands
    Disabled byskip-named-commands

    Enable namedmysql commands. Long-format commands are permitted, not just short-format commands. For example,quit and\q both are recognized. Use--skip-named-commands to disable named commands. SeeSection 4.5.1.2, “mysql Client Commands”.

  • --net-buffer-length=value

    Command-Line Format--net-buffer-length=value
    TypeNumeric
    Default Value16384

    The buffer size for TCP/IP and socket communication. (Default value is 16KB.)

  • --no-auto-rehash,-A

    Command-Line Format--no-auto-rehash
    DeprecatedYes

    This has the same effect as--skip-auto-rehash. See the description for--auto-rehash.

  • --no-beep,-b

    Command-Line Format--no-beep

    Do not beep when errors occur.

  • --no-defaults

    Command-Line Format--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.

    The exception is that the.mylogin.cnf file is read in all cases, if it exists. This permits passwords to be specified in a safer way than on the command line even when--no-defaults is used. To create.mylogin.cnf, use themysql_config_editor utility. SeeSection 4.6.6, “mysql_config_editor — MySQL Configuration Utility”.

    For additional information about this and other option-file options, seeSection 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.

  • --one-database,-o

    Command-Line Format--one-database

    Ignore statements except those that occur while the default database is the one named on the command line. This option is rudimentary and should be used with care. Statement filtering is based only onUSE statements.

    Initially,mysql executes statements in the input because specifying a databasedb_name on the command line is equivalent to insertingUSEdb_name at the beginning of the input. Then, for eachUSE statement encountered,mysql accepts or rejects following statements depending on whether the database named is the one on the command line. The content of the statements is immaterial.

    Suppose thatmysql is invoked to process this set of statements:

    DELETE FROM db2.t2;USE db2;DROP TABLE db1.t1;CREATE TABLE db1.t1 (i INT);USE db1;INSERT INTO t1 (i) VALUES(1);CREATE TABLE db2.t1 (j INT);

    If the command line ismysql --force --one-database db1,mysql handles the input as follows:

    • TheDELETE statement is executed because the default database isdb1, even though the statement names a table in a different database.

    • TheDROP TABLE andCREATE TABLE statements are not executed because the default database is notdb1, even though the statements name a table indb1.

    • TheINSERT andCREATE TABLE statements are executed because the default database isdb1, even though theCREATE TABLE statement names a table in a different database.

  • --pager[=command]

    Command-Line Format--pager[=command]
    Disabled byskip-pager
    TypeString

    Use the given command for paging query output. If the command is omitted, the default pager is the value of yourPAGER environment variable. Valid pagers areless,more,cat [> filename], and so forth. This option works only on Unix and only in interactive mode. To disable paging, use--skip-pager.Section 4.5.1.2, “mysql Client Commands”, discusses output paging further.

  • --password[=password],-p[password]

    Command-Line Format--password[=password]
    TypeString

    The password of the MySQL account used for connecting to the server. The password value is optional. If not given,mysql prompts for one. If given, there must beno space between--password= or-p and the password following it. If no password option is specified, the default is to send no password.

    Specifying a password on the command line should be considered insecure. To avoid giving the password on the command line, use an option file. SeeSection 6.1.2.1, “End-User Guidelines for Password Security”.

    To explicitly specify that there is no password and thatmysql should not prompt for one, use the--skip-password option.

  • --pipe,-W

    Command-Line Format--pipe
    TypeString

    On Windows, connect to the server using a named pipe. This option applies only if the server was started with thenamed_pipe system variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by thenamed_pipe_full_access_group system variable.

  • --plugin-dir=dir_name

    Command-Line Format--plugin-dir=dir_name
    TypeDirectory name

    The directory in which to look for plugins. Specify this option if the--default-auth option is used to specify an authentication plugin butmysql does not find it. SeeSection 6.2.13, “Pluggable Authentication”.

  • --port=port_num,-Pport_num

    Command-Line Format--port=port_num
    TypeNumeric
    Default Value3306

    For TCP/IP connections, the port number to use.

  • --print-defaults

    Command-Line Format--print-defaults

    Print the program name and all options that it gets from option files.

    For additional information about this and other option-file options, seeSection 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.

  • --prompt=format_str

    Command-Line Format--prompt=format_str
    TypeString
    Default Valuemysql>

    Set the prompt to the specified format. The default ismysql>. The special sequences that the prompt can contain are described inSection 4.5.1.2, “mysql Client Commands”.

  • --protocol={TCP|SOCKET|PIPE|MEMORY}

    Command-Line Format--protocol=type
    TypeString
    Default Value[see text]
    Valid Values

    TCP

    SOCKET

    PIPE

    MEMORY

    The transport protocol to use for connecting to the server. It is useful when the other connection parameters normally result in use of a protocol other than the one you want. For details on the permissible values, seeSection 4.2.5, “Connection Transport Protocols”.

  • --quick,-q

    Command-Line Format--quick

    Do not cache each query result, print each row as it is received. This may slow down the server if the output is suspended. With this option,mysql does not use the history file.

    By default,mysql fetches all result rows before producing any output; while storing these, it calculates a running maximum column length from the actual value of each column in succession. When printing the output, it uses this maximum to format it. When--quick is specified,mysql does not have the rows for which to calculate the length before starting, and so uses the maximum length. In the following example, tablet1 has a single column of typeBIGINT and containing 4 rows. The default output is 9 characters wide; this width is equal the maximum number of characters in any of the column values in the rows returned (5), plus 2 characters each for the spaces used as padding and the| characters used as column delimiters). The output when using the--quick option is 25 characters wide; this is equal to the number of characters needed to represent-9223372036854775808, which is the longest possible value that can be stored in a (signed)BIGINT column, or 19 characters, plus the 4 characters used for padding and column delimiters. The difference can be seen here:

    $> mysql -t test -e "SELECT * FROM t1"+-------+| c1    |+-------+|   100 ||  1000 || 10000 ||    10 |+-------+$> mysql --quick -t test -e "SELECT * FROM t1"+----------------------+| c1                   |+----------------------+|                  100 ||                 1000 ||                10000 ||                   10 |+----------------------+
  • --raw,-r

    Command-Line Format--raw

    For tabular output, theboxing around columns enables one column value to be distinguished from another. For nontabular output (such as is produced in batch mode or when the--batch or--silent option is given), special characters are escaped in the output so they can be identified easily. Newline, tab,NUL, and backslash are written as\n,\t,\0, and\\. The--raw option disables this character escaping.

    The following example demonstrates tabular versus nontabular output and the use of raw mode to disable escaping:

    % mysqlmysql> SELECT CHAR(92);+----------+| CHAR(92) |+----------+| \        |+----------+% mysql -smysql> SELECT CHAR(92);CHAR(92)\\% mysql -s -rmysql> SELECT CHAR(92);CHAR(92)\
  • --reconnect

    Command-Line Format--reconnect
    Disabled byskip-reconnect

    If the connection to the server is lost, automatically try to reconnect. A single reconnect attempt is made each time the connection is lost. To suppress reconnection behavior, use--skip-reconnect.

  • --safe-updates,--i-am-a-dummy,-U

    Command-Line Format

    --safe-updates

    --i-am-a-dummy

    TypeBoolean
    Default ValueFALSE

    If this option is enabled,UPDATE andDELETE statements that do not use a key in theWHERE clause or aLIMIT clause produce an error. In addition, restrictions are placed onSELECT statements that produce (or are estimated to produce) very large result sets. If you have set this option in an option file, you can use--skip-safe-updates on the command line to override it. For more information about this option, seeUsing Safe-Updates Mode (--safe-updates).

  • --secure-auth

    Command-Line Format--secure-auth
    DeprecatedYes

    Do not send passwords to the server in old (pre-4.1) format. This prevents connections except for servers that use the newer password format.

    As of MySQL 5.7.5, this option is deprecated; expect it to be removed in a future MySQL release. It is always enabled and attempting to disable it (--skip-secure-auth,--secure-auth=0) produces an error. Before MySQL 5.7.5, this option is enabled by default but can be disabled.

    Note

    Passwords that use the pre-4.1 hashing method are less secure than passwords that use the native password hashing method and should be avoided. Pre-4.1 passwords are deprecated and support for them was removed in MySQL 5.7.5. For account upgrade instructions, seeSection 6.4.1.3, “Migrating Away from Pre-4.1 Password Hashing and the mysql_old_password Plugin”.

  • --select-limit=value

    Command-Line Format--select-limit=value
    TypeNumeric
    Default Value1000

    The automatic limit forSELECT statements when using--safe-updates. (Default value is 1,000.)

  • --server-public-key-path=file_name

    Command-Line Format--server-public-key-path=file_name
    TypeFile name

    The path name to a file in PEM format containing a client-side copy of the public key required by the server for RSA key pair-based password exchange. This option applies to clients that authenticate with thesha256_password orcaching_sha2_password authentication plugin. This option is ignored for accounts that do not authenticate with one of those plugins. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.

    If--server-public-key-path=file_name is given and specifies a valid public key file, it takes precedence over--get-server-public-key.

    Forsha256_password, this option applies only if MySQL was built using OpenSSL.

    For information about thesha256_password andcaching_sha2_password plugins, seeSection 6.4.1.5, “SHA-256 Pluggable Authentication”, andSection 6.4.1.4, “Caching SHA-2 Pluggable Authentication”.

  • --shared-memory-base-name=name

    Command-Line Format--shared-memory-base-name=name
    Platform SpecificWindows

    On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value isMYSQL. The shared-memory name is case-sensitive.

    This option applies only if the server was started with theshared_memory system variable enabled to support shared-memory connections.

  • --show-warnings

    Command-Line Format--show-warnings

    Cause warnings to be shown after each statement if there are any. This option applies to interactive and batch mode.

  • --sigint-ignore

    Command-Line Format--sigint-ignore

    IgnoreSIGINT signals (typically the result of typingControl+C).

    Without this option, typingControl+C interrupts the current statement if there is one, or cancels any partial input line otherwise.

  • --silent,-s

    Command-Line Format--silent

    Silent mode. Produce less output. This option can be given multiple times to produce less and less output.

    This option results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the--raw option.

  • --skip-column-names,-N

    Command-Line Format--skip-column-names

    Do not write column names in results. Use of this option causes the output to be right-aligned, as shown here:

    $> echo "SELECT * FROM t1" | mysql -t test+-------+| c1    |+-------+| a,c,d || c     |+-------+$> echo "SELECT * FROM t1" | ./mysql -uroot -Nt test+-------+| a,c,d ||     c |+-------+
  • --skip-line-numbers,-L

    Command-Line Format--skip-line-numbers

    Do not write line numbers for errors. Useful when you want to compare result files that include error messages.

  • --socket=path,-Spath

    Command-Line Format--socket={file_name|pipe_name}
    TypeString

    For connections tolocalhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.

    On Windows, this option applies only if the server was started with thenamed_pipe system variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by thenamed_pipe_full_access_group system variable.

  • --ssl*

    Options that begin with--ssl specify whether to connect to the server using encryption and indicate where to find SSL keys and certificates. SeeCommand Options for Encrypted Connections.

  • --syslog,-j

    Command-Line Format--syslog

    This option causesmysql to send interactive statements to the system logging facility. On Unix, this issyslog; on Windows, it is the Windows Event Log. The destination where logged messages appear is system dependent. On Linux, the destination is often the/var/log/messages file.

    Here is a sample of output generated on Linux by using--syslog. This output is formatted for readability; each logged message actually takes a single line.

    Mar  7 12:39:25 myhost MysqlClient[20824]:  SYSTEM_USER:'oscar', MYSQL_USER:'my_oscar', CONNECTION_ID:23,  DB_SERVER:'127.0.0.1', DB:'--', QUERY:'USE test;'Mar  7 12:39:28 myhost MysqlClient[20824]:  SYSTEM_USER:'oscar', MYSQL_USER:'my_oscar', CONNECTION_ID:23,  DB_SERVER:'127.0.0.1', DB:'test', QUERY:'SHOW TABLES;'

    For more information, seeSection 4.5.1.3, “mysql Client Logging”.

  • --table,-t

    Command-Line Format--table

    Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode.

  • --tee=file_name

    Command-Line Format--tee=file_name
    TypeFile name

    Append a copy of output to the given file. This option works only in interactive mode.Section 4.5.1.2, “mysql Client Commands”, discusses tee files further.

  • --tls-version=protocol_list

    Command-Line Format--tls-version=protocol_list
    Introduced5.7.10
    TypeString
    Default Value (≥ 5.7.28)TLSv1,TLSv1.1,TLSv1.2
    Default Value (≤ 5.7.27)

    TLSv1,TLSv1.1,TLSv1.2 (OpenSSL)

    TLSv1,TLSv1.1 (yaSSL)

    The permissible TLS protocols for encrypted connections. The value is a list of one or more comma-separated protocol names. The protocols that can be named for this option depend on the SSL library used to compile MySQL. For details, seeSection 6.3.2, “Encrypted Connection TLS Protocols and Ciphers”.

    This option was added in MySQL 5.7.10.

  • --unbuffered,-n

    Command-Line Format--unbuffered

    Flush the buffer after each query.

  • --user=user_name,-uuser_name

    Command-Line Format--user=user_name
    TypeString

    The user name of the MySQL account to use for connecting to the server.

  • --verbose,-v

    Command-Line Format--verbose

    Verbose mode. Produce more output about what the program does. This option can be given multiple times to produce more and more output. (For example,-v -v -v produces table output format even in batch mode.)

  • --version,-V

    Command-Line Format--version

    Display version information and exit.

  • --vertical,-E

    Command-Line Format--vertical

    Print query output rows vertically (one line per column value). Without this option, you can specify vertical output for individual statements by terminating them with\G.

  • --wait,-w

    Command-Line Format--wait

    If the connection cannot be established, wait and retry instead of aborting.

  • --xml,-X

    Command-Line Format--xml

    Produce XML output.

    <field name="column_name">NULL</field>

    The output when--xml is used withmysql matches that ofmysqldump--xml. SeeSection 4.5.4, “mysqldump — A Database Backup Program”, for details.

    The XML output also uses an XML namespace, as shown here:

    $> mysql --xml -uroot -e "SHOW VARIABLES LIKE 'version%'"<?xml version="1.0"?><resultset statement="SHOW VARIABLES LIKE 'version%'" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><row><field name="Variable_name">version</field><field name="Value">5.0.40-debug</field></row><row><field name="Variable_name">version_comment</field><field name="Value">Source distribution</field></row><row><field name="Variable_name">version_compile_machine</field><field name="Value">i686</field></row><row><field name="Variable_name">version_compile_os</field><field name="Value">suse-linux-gnu</field></row></resultset>