4.5.1.1. mysql Options

mysql supports the following options, which can be specified on the command line or in the [mysql] and [client] option file groups. mysql also supports the options for processing option files described at Section 4.2.3.3.1, “Command-Line Options that Affect Option-File Handling”.

Table 4.2. mysql Options

FormatOption FileDescriptionIntroductionDeprecatedRemoved
--auto-rehashauto-rehashEnable automatic rehashing   
--auto-vertical-outputauto-vertical-outputEnable automatic vertical result set display5.5.3  
--batchbatchDon't use history file   
--bind-address=ip_addressbind-addressUse the specified network interface to connect to the MySQL Server5.5.8  
--character-sets-dir=pathcharacter-sets-dirSet the default character set   
--column-namescolumn-namesWrite column names in results   
--column-type-infocolumn-type-infoDisplay result set metadata   
--commentscommentsWhether to retain or strip comments in statements sent to the server   
--compresscompressCompress all information sent between the client and the server   
--connect_timeout=valueconnect_timeoutThe number of seconds before connection timeout   
--database=dbnamedatabaseThe database to use   
--debug[=debug_options]debugWrite a debugging log   
--debug-checkdebug-checkPrint debugging information when the program exits   
--debug-infodebug-infoPrint debugging information, memory and CPU statistics when the program exits   
--default-auth=plugindefault-auth=pluginThe authentication plugin to use5.5.7  
--default-character-set=charset_namedefault-character-setUse charset_name as the default character set   
--delimiter=strdelimiterSet the statement delimiter   
--execute=statementexecuteExecute the statement and quit   
--forceforceContinue even if an SQL error occurs   
--help Display help message and exit   
--host=host_namehostConnect to the MySQL server on the given host   
--htmlhtmlProduce HTML output   
--ignore-spacesignore-spacesIgnore spaces after function names   
--line-numbersline-numbersWrite line numbers for errors   
--local-infile[={0|1}]local-infileEnable or disable for LOCAL capability for LOAD DATA INFILE   
--max_allowed_packet=valuemax_allowed_packetThe maximum packet length to send to or receive from the server   
--max_join_size=valuemax_join_sizeThe automatic limit for rows in a join when using --safe-updates   
--named-commandsnamed-commandsEnable named mysql commands   
--net_buffer_length=valuenet_buffer_lengthThe buffer size for TCP/IP and socket communication   
--no-auto-rehash Disable automatic rehashing   
--no-beepno-beepDo not beep when errors occur   
--no-named-commandsno-named-commandsDisable named mysql commands  5.5.3
--no-pagerno-pagerDeprecated form of --skip-pager  5.5.3
--no-teeno-teeDo not copy output to a file  5.5.3
--one-databaseone-databaseIgnore statements except those for the default database named on the command line   
--pager[=command]pagerUse the given command for paging query output   
--password[=password]passwordThe password to use when connecting to the server   
--plugin-dir=pathplugin-dir=pathThe directory where plugins are located5.5.7  
--port=port_numportThe TCP/IP port number to use for the connection   
--prompt=format_strpromptSet the prompt to the specified format   
--protocol=typeprotocolThe connection protocol to use   
--quickquickDo not cache each query result   
--rawrawWrite column values without escape conversion   
--reconnectreconnectIf the connection to the server is lost, automatically try to reconnect   
--safe-updatessafe-updatesAllow only UPDATE and DELETE statements that specify key values   
--secure-authsecure-authDo not send passwords to the server in old (pre-4.1.1) format   
--select_limit=valueselect_limitThe automatic limit for SELECT statements when using --safe-updates   
--show-warningsshow-warningsShow warnings after each statement if there are any   
--sigint-ignoresigint-ignoreIgnore SIGINT signals (typically the result of typing Control-C)   
--silentsilentSilent mode   
--skip-auto-rehashskip-auto-rehashDisable automatic rehashing   
--skip-column-namesskip-column-namesDo not write column names in results   
--skip-line-numbersskip-line-numbersSkip line numbers for errors   
--skip-named-commandsskip-named-commandsDisable named mysql commands   
--skip-pagerskip-pagerDisable paging   
--skip-reconnectskip-reconnectDisable reconnecting   
--socket=pathsocketFor connections to localhost   
--ssl-ca=file_namessl-caThe path to a file that contains a list of trusted SSL CAs   
--ssl-capath=directory_namessl-capathThe path to a directory that contains trusted SSL CA certificates in PEM format   
--ssl-cert=file_namessl-certThe name of the SSL certificate file to use for establishing a secure connection   
--ssl-cipher=cipher_listssl-cipherA list of allowable ciphers to use for SSL encryption   
--ssl-key=file_namessl-keyThe name of the SSL key file to use for establishing a secure connection   
--ssl-verify-server-certssl-verify-server-certThe server's Common Name value in its certificate is verified against the host name used when connecting to the server   
--tabletableDisplay output in tabular format   
--tee=file_nameteeAppend a copy of output to the given file   
--unbufferedunbufferedFlush the buffer after each query   
--user=user_nameuserThe MySQL user name to use when connecting to the server   
--verbose Verbose mode   
--version Display version information and exit   
--verticalverticalPrint query output rows vertically (one line per column value)   
--waitwaitIf the connection cannot be established, wait and retry instead of aborting   
--xmlxmlProduce XML output   
  • --help, -?

    Display a help message and exit.

  • --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 causes mysql to start faster, but you must issue the rehash command 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.

  • --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.) This option was added in MySQL 5.5.3.

  • --batch, -B

    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.

  • --bind-address=ip_address

    On a computer having multiple network interfaces, this option can be used to select which interface is employed when connecting to the MySQL server.

    This option is supported beginning with MySQL 5.5.8.

  • --character-sets-dir=path

    The directory where character sets are installed. See Section 9.5, “Character Set Configuration”.

  • --column-names

    Write column names in results.

  • --column-type-info, -m

    Display result set metadata.

  • --comments, -c

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

  • --compress, -C

    Compress all information sent between the client and the server if both support compression.

  • --database=db_name, -D db_name

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

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

    Write a debugging log. A typical debug_options string is 'd:t:o,file_name'. The default is 'd:t:o,/tmp/mysql.trace'.

  • --debug-check

    Print some debugging information when the program exits.

  • --debug-info, -T

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

  • --default-auth=plugin

    The client-side authentication plugin to use. See Section 5.5.6, “Pluggable Authentication”.

    This option was added in MySQL 5.5.7.

  • --default-character-set=charset_name

    Use charset_name as the default character set for the client and connection.

    A common issue that can occur when the operating system uses utf8 or another multi-byte character set is that output from the mysql client is formatted incorrectly, due to the fact that the MySQL client uses the latin1 character set by default. You can usually fix such issues by using this option to force the client to use the system character set instead.

    See Section 9.5, “Character Set Configuration”, for more information.

  • --delimiter=str

    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 option enabled by default. However, even with this option, long-format commands still work from the first line. See Section 4.5.1.2, “mysql Commands”.

  • --execute=statement, -e statement

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

  • --force, -f

    Continue even if an SQL error occurs.

  • --host=host_name, -h host_name

    Connect to the MySQL server on the given host.

  • --html, -H

    Produce HTML output.

  • --ignore-spaces, -i

    Ignore spaces after function names. The effect of this is described in the discussion for the IGNORE_SPACE SQL mode (see Section 5.1.7, “Server SQL Modes”).

  • --line-numbers

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

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

    Enable or disable LOCAL capability for LOAD DATA INFILE. With no value, the option enables LOCAL. The option may be given as --local-infile=0 or --local-infile=1 to explicitly disable or enable LOCAL. Enabling LOCAL has no effect if the server does not also support it.

  • --named-commands, -G

    Enable named mysql 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. See Section 4.5.1.2, “mysql Commands”.

  • --no-auto-rehash, -A

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

  • --no-beep, -b

    Do not beep when errors occur.

  • --no-named-commands, -g

    Deprecated, use --disable-named-commands instead. --no-named-commands was removed in MySQL 5.5.3.

  • --no-pager

    Deprecated form of --skip-pager. See the --pager option. --no-pager was removed in MySQL 5.5.3.

  • --no-tee

    Deprecated form of --skip-tee. See the --tee option. --no-tee is removed in MySQL 5.5.3.

  • --one-database, -o

    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 on USE statements.

    Initially, mysql executes statements in the input because specifying a database db_name on the command line is equivalent to inserting USE db_name at the beginning of the input. Then, for each USE 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 that mysql 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 is mysql --force --one-database db1, mysql handles the input as follows:

    • The DELETE statement is executed because the default database is db1, even though the statement names a table in a different database.

    • The DROP TABLE and CREATE TABLE statements are not executed because the default database is not db1, even though the statements name a table in db1.

    • The INSERT and CREATE TABLE statements are executed because the default database is db1, even though the CREATE TABLE statement names a table in a different database.

  • --pager[=command]

    Use the given command for paging query output. If the command is omitted, the default pager is the value of your PAGER environment variable. Valid pagers are less, 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 Commands”, discusses output paging further.

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

    The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mysql prompts for one.

    Specifying a password on the command line should be considered insecure. See Section 5.3.2.2, “End-User Guidelines for Password Security”. You can use an option file to avoid giving the password on the command line.

  • --pipe, -W

    On Windows, connect to the server using a named pipe. This option applies only if the server supports named-pipe connections.

  • --plugin-dir=path

    The directory in which to look for plugins. It may be necessary to specify this option if the --default-auth option is used to specify an authentication plugin but mysql does not find it. See Section 5.5.6, “Pluggable Authentication”.

    This option was added in MySQL 5.5.7.

  • --port=port_num, -P port_num

    The TCP/IP port number to use for the connection.

  • --prompt=format_str

    Set the prompt to the specified format. The default is mysql>. The special sequences that the prompt can contain are described in Section 4.5.1.2, “mysql Commands”.

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

    The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the permissible values, see Section 4.2.2, “Connecting to the MySQL Server”.

  • --quick, -q

    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.

  • --raw, -r

    For tabular output, the “boxing” 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:

    % mysql
    mysql> SELECT CHAR(92);
    +----------+
    | CHAR(92) |
    +----------+
    | \        |
    +----------+
    
    % mysql -s
    mysql> SELECT CHAR(92);
    CHAR(92)
    \\
    
    % mysql -s -r
    mysql> SELECT CHAR(92);
    CHAR(92)
    \
    
  • --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

    Permit only those UPDATE and DELETE statements that specify which rows to modify by using key values. If you have set this option in an option file, you can override it by using --safe-updates on the command line. See Section 4.5.1.6, “mysql Tips”, for more information about this option.

  • --secure-auth

    Do not send passwords to the server in old (pre-4.1.1) format. This prevents connections except for servers that use the newer password 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

    Ignore SIGINT signals (typically the result of typing Control-C).

  • --silent, -s

    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

    Do not write column names in results.

  • --skip-line-numbers, -L

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

  • --socket=path, -S path

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

  • --ssl*

    Options that begin with --ssl specify whether to connect to the server using SSL and indicate where to find SSL keys and certificates. See Section 5.5.8.3, “SSL Command Options”.

  • --table, -t

    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

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

  • --unbuffered, -n

    Flush the buffer after each query.

  • --user=user_name, -u user_name

    The MySQL user name to use when connecting to the server.

  • --verbose, -v

    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

    Display version information and exit.

  • --vertical, -E

    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

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

  • --xml, -X

    Produce XML output.

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

    The output when --xml is used with mysql matches that of mysqldump --xml. See Section 4.5.4, “mysqldump — A Database Backup Program” for details.

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

    shell> 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>
    

    (See Bug#25946.)

You can also set the following variables by using --var_name=value. The --set-variable format is deprecated and was removed in MySQL 5.5.3.

  • connect_timeout

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

  • max_allowed_packet

    The maximum packet length to send to or receive from the server. (Default value is 16MB.)

  • max_join_size

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

  • net_buffer_length

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

  • select_limit

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

Copyright © 2010-2024 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout