Menu:
mysqlslap:: mysqlslap -- A Load Emulation Client
This section describes client programs that connect to the MySQL server.
File: manual.info.tmp, Node: mysql, Next: mysqladmin, Prev: programs-client, Up: programs-client
Menu:
mysql-tips:: mysql Client Tips
*note 'mysql': mysql. is a simple SQL shell with input line editing capabilities. It supports interactive and noninteractive use. When used interactively, query results are presented in an ASCII-table format. When used noninteractively (for example, as a filter), the result is presented in tab-separated format. The output format can be changed using command options.
If you have problems due to insufficient memory for large result sets, use the '--quick' option. This forces *note 'mysql': mysql. to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it. This is done by returning the result set using the 'mysql_use_result()' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-use-result.html) C API function in the client/server library rather than 'mysql_store_result()' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-store-result.html).
Note:
Alternatively, MySQL Shell offers access to the X DevAPI. For details, see MySQL Shell 8.0 (https://dev.mysql.com/doc/mysql-shell/8.0/en/).
Using *note 'mysql': mysql. is very easy. Invoke it from the prompt of your command interpreter as follows:
mysql DB_NAME
Or:
mysql --user=USER_NAME --password DB_NAME
In this case, you'll need to enter your password in response to the prompt that *note 'mysql': mysql. displays:
Enter password: YOUR_PASSWORD
Then type an SQL statement, end it with ';', '', or '' and press Enter.
Typing 'Control+C' interrupts the current statement if there is one, or cancels any partial input line otherwise.
You can execute SQL statements in a script file (batch file) like this:
mysql DB_NAME < SCRIPT.SQL > OUTPUT.TAB
On Unix, the note 'mysql': mysql. client logs statements executed interactively to a history file. See note mysql-logging::.
File: manual.info.tmp, Node: mysql-command-options, Next: mysql-commands, Prev: mysql, Up: mysql
4.5.1.1 mysql Client Options ............................
note 'mysql': 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, see note option-files::.
mysql Client Options
Option Name Description IntroducedDeprecated
-auto-rehash
Enable automatic rehashing
-auto-vertical-output
Enable automatic vertical result set display
-batch
Do not use history file
-binary-as-hex
Display binary 5.7.19 values in
hexadecimal notation
-binary-mode
Disable - to - translation and treatment of as end-of-query
-bind-address
Use specified network interface to connect to MySQL Server
-character-sets-dir
Directory where character sets are installed
-column-names
Write column names in results
-column-type-info
Display result set metadata
-comments
Whether to retain or strip comments in statements sent to the server
-compress
Compress all information sent between client and server
-connect-expired-password
Indicate to server that client can handle expired-password sandbox mode
-connect-timeout
Number of seconds before connection timeout
-database
The database to use
-debug
Write debugging log; supported only if MySQL was built with debugging support
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-default-character-set
Specify default character set
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-delimiter
Set the statement delimiter
-enable-cleartext-plugin
Enable cleartext authentication plugin
-execute
Execute the statement and quit
-force
Continue even if an SQL error occurs
-get-server-public-key
Request RSA 5.7.23 public key from
server
-help
Display help message and exit
-histignore
Patterns specifying which statements to ignore for logging
-host
Host on which MySQL server is located
-html
Produce HTML output
-ignore-spaces
Ignore spaces after function names
-init-command
SQL statement to execute after connecting
-line-numbers
Write line numbers for errors
-local-infile
Enable or disable for LOCAL capability for LOAD DATA
-login-path
Read login path options from .mylogin.cnf
-max-allowed-packet
Maximum packet length to send to or receive from server
-max-join-size
The automatic limit for rows in a join when using -safe-updates
-named-commands
Enable named mysql commands
-net-buffer-length
Buffer size for TCP/IP and socket communication
-no-auto-rehash
Disable automatic rehashing
-no-beep
Do not beep when errors occur
-no-defaults
Read no option files
-one-database
Ignore statements except those for the default database named on the command line
-pager
Use the given command for paging query output
-password
Password to use when connecting to server
-pipe
Connect to server using named pipe (Windows only)
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-print-defaults
Print default options
-prompt
Set the prompt to the specified format
-protocol
Transport protocol to use
-quick
Do not cache each query result
-raw
Write column values without escape conversion
-reconnect
If the connection to the server is lost, automatically try to reconnect
-safe-updates, -i-am-a-dummy
Allow only UPDATE and DELETE statements that specify key values
-secure-auth
Do not send Yes passwords to
server in old (pre-4.1) format
-select-limit
The automatic limit for SELECT statements when using -safe-updates
-server-public-key-path
Path name to file containing RSA public key
-shared-memory-base-name
Shared-memory name for shared-memory connections (Windows only)
-show-warnings
Show warnings after each statement if there are any
-sigint-ignore
Ignore SIGINT signals (typically the result of typing Control+C)
-silent
Silent mode
-skip-auto-rehash
Disable automatic rehashing
-skip-column-names
Do not write column names in results
-skip-line-numbers
Skip line numbers for errors
-skip-named-commands
Disable named mysql commands
-skip-pager
Disable paging
-skip-reconnect
Disable reconnecting
-socket
Unix socket file or Windows named pipe to use
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of
connection to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-syslog
Log interactive statements to syslog
-table
Display output in tabular format
-tee
Append a copy of output to named file
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-unbuffered
Flush the buffer after each query
-user
MySQL user name to use when connecting to server
-verbose
Verbose mode
-version
Display version information and exit
-vertical
Print query output rows vertically (one line per column value)
-wait
If the connection cannot be established, wait and retry instead of aborting
-xml
Produce XML output
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--auto-rehash'
Command-Line Format
'--auto-rehash'
Disabled by
'skip-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 *note 'mysql': mysql. to start faster, but you must issue the 'rehash' 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, *note 'mysql': 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 the readline library. Typically, the readline 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 ''.)
'--batch', '-B'
Command-Line Format
'--batch'
Print results using tab as the column separator, with each row on a new line. With this option, *note 'mysql': 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'
Introduced
5.7.19
Type
Boolean
Default Value
'FALSE'
When this option is given, *note 'mysql': 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 as 'CHAR()' and 'UNHEX()'. The following example demonistrates this using the ASCII code for 'A' (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:
* The 'CHAR()' function has a 'USING CHARSET' clause:
mysql> SELECT CHAR(0x41 USING utf8mb4);
+--------------------------+
| CHAR(0x41 USING utf8mb4) |
+--------------------------+
| A |
+--------------------------+
* More generally, use 'CONVERT()' 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 processing note 'mysqlbinlog': mysqlbinlog. output that may contain note 'BLOB': blob. values. By default, note 'mysql': mysql. translates '' in statement strings to '' and interprets '' as the statement terminator. '--binary-mode' disables both features. It also disables all note 'mysql': mysql. commands except 'charset' and 'delimiter' in noninteractive mode (for input piped to *note 'mysql': mysql. or loaded using the 'source' command).
'--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'
Type
Directory name
The directory where character sets are installed. See *note charset-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 API 'MYSQL_FIELD' data structures. See C API Basic Data Structures (https://dev.mysql.com/doc/c-api/5.7/en/c-api-data-structures.html).
'--comments', '-c'
Command-Line Format
'--comments'
Type
Boolean
Default Value
'FALSE'
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, the note 'mysql': mysql. 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 the note 'mysql': mysql. client with a version of the server that understands optimizer hints, invoke *note 'mysql': mysql. 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}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note 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 of note 'mysql': mysql. because normally the server disconnects noninteractive clients that attempt to connect using an account with an expired password. (See note expired-password-handling::.)
'--connect-timeout=VALUE'
Command-Line Format
'--connect-timeout=value'
Type
Numeric
Default Value
'0'
The number of seconds before connection timeout. (Default value is '0'.)
'--database=DB_NAME', '-D DB_NAME'
Command-Line Format
'--database=dbname'
Type
String
The database to use. This is useful primarily in an option file.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:o,/tmp/mysql.trace'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default is 'd:t:o,/tmp/mysql.trace'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info', '-T'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--default-character-set=CHARSET_NAME'
Command-Line Format
'--default-character-set=charset_name'
Type
String
Use CHARSET_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 the *note 'mysql': mysql. 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, see note charset-connection::, and note charset-configuration::.
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysql': mysql. normally reads the '[client]' and '[mysql]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysql': mysql. also reads the '[client_other]' and '[mysql_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--delimiter=STR'
Command-Line Format
'--delimiter=str'
Type
String
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 (';'). note 'mysql': mysql. starts with this option enabled by default. However, even with this option, long-format commands still work from the first line. See note mysql-commands::.
'--enable-cleartext-plugin'
Command-Line Format
'--enable-cleartext-plugin'
Type
Boolean
Default Value
'FALSE'
Enable the 'mysql_clear_password' cleartext authentication plugin. (See *note cleartext-pluggable-authentication::.)
'--execute=STATEMENT', '-e STATEMENT'
Command-Line Format
'--execute=statement'
Type
String
Execute the statement and quit. The default output format is like that produced with '--batch'. See note command-line-options::, for some examples. With this option, note 'mysql': 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'
Introduced
5.7.23
Type
Boolean
Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the 'caching_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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--histignore'
Command-Line Format
'--histignore=pattern_list'
Type
String
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 to 'syslog' if the '--syslog' option is given. For more information, see *note mysql-logging::.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host=host_name'
Type
String
Default Value
'localhost'
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 the 'IGNORE_SPACE' SQL mode (see *note sql-mode::).
'--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 by
'skip-line-numbers'
Write line numbers for errors. Disable this with '--skip-line-numbers'.
'--local-infile[={0|1}]'
Command-Line Format
'--local-infile[={0|1}]'
Type
Boolean
Default Value
'FALSE'
By default, 'LOCAL' capability for *note 'LOAD DATA': load-data. is determined by the default compiled into the MySQL client library. To enable or disable 'LOCAL' data loading explicitly, use the '--local-infile' option. When given with no value, the option enables 'LOCAL' data loading. When given as '--local-infile=0' or '--local-infile=1', the option disables or enables 'LOCAL' data loading.
Successful use of 'LOCAL' load operations within note 'mysql': mysql. also requires that the server permits local loading; see note load-data-local-security::
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--max-allowed-packet=VALUE'
Command-Line Format
'--max-allowed-packet=value'
Type
Numeric
Default Value
'16777216'
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'
Type
Numeric
Default Value
'1000000'
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 by
'skip-named-commands'
Enable named note 'mysql': mysql. commands. Long-format commands are permitted, not just short-format commands. For example, 'quit' and '' both are recognized. Use '--skip-named-commands' to disable named commands. See note mysql-commands::.
'--net-buffer-length=VALUE'
Command-Line Format
'--net-buffer-length=value'
Type
Numeric
Default Value
'16384'
The buffer size for TCP/IP and socket communication. (Default value is 16KB.)
'--no-auto-rehash', '-A'
Command-Line Format
'--no-auto-rehash'
Deprecated
Yes
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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--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 on *note 'USE': use. statements.
Initially, note 'mysql': mysql. executes statements in the input because specifying a database DB_NAME on the command line is equivalent to inserting note 'USE DB_NAME': use. at the beginning of the input. Then, for each note 'USE': use. statement encountered, note 'mysql': 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 *note 'mysql': 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 note 'mysql --force --one-database db1': mysql, note 'mysql': mysql. handles the input as follows:
* The *note 'DELETE': delete. statement is executed because the
default database is 'db1', even though the statement names a
table in a different database.
* The *note 'DROP TABLE': drop-table. and *note 'CREATE TABLE':
create-table. statements are not executed because the default
database is not 'db1', even though the statements name a table
in 'db1'.
* The *note 'INSERT': insert. and *note 'CREATE TABLE':
create-table. statements are executed because the default
database is 'db1', even though the *note 'CREATE TABLE':
create-table. statement names a table in a different database.
'--pager[=COMMAND]'
Command-Line Format
'--pager[=command]'
Disabled by
'skip-pager'
Type
String
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'. *note mysql-commands::, discusses output paging further.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysql': mysql. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysql': mysql. should not prompt for one, use the '--skip-password' option.
'--pipe', '-W'
Command-Line Format
'--pipe'
Type
String
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the 'named_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 the 'named_pipe_full_access_group' system variable.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysql': mysql. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
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, see *note option-file-options::.
'--prompt=FORMAT_STR'
Command-Line Format
'--prompt=format_str'
Type
String
Default Value
'mysql>'
Set the prompt to the specified format. The default is 'mysql>'. The special sequences that the prompt can contain are described in *note mysql-commands::.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note 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, *note 'mysql': mysql. does not use the history file.
By default, note 'mysql': 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, note 'mysql': mysql. does not have the rows for which to calculate the length before starting, and so uses the maximum length. In the following example, table 't1' has a single column of type *note 'BIGINT': integer-types. 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, 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 '', '', '', 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'
Command-Line Format
'--reconnect'
Disabled by
'skip-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'
Type
Boolean
Default Value
'FALSE'
If this option is enabled, note 'UPDATE': update. and note 'DELETE': delete. statements that do not use a key in the 'WHERE' clause or a 'LIMIT' clause produce an error. In addition, restrictions are placed on note 'SELECT': select. 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, see note safe-updates::.
'--secure-auth'
Command-Line Format
'--secure-auth'
Deprecated
Yes
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, see *note account-upgrades::.
'--select-limit=VALUE'
Command-Line Format
'--select-limit=value'
Type
Numeric
Default Value
'1000'
The automatic limit for *note 'SELECT': select. 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'
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
'--shared-memory-base-name=NAME'
Command-Line Format
'--shared-memory-base-name=name'
Platform Specific
Windows
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 'MYSQL'. The shared-memory name is case-sensitive.
This option applies only if the server was started with the 'shared_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'
Ignore 'SIGINT' signals (typically the result of typing 'Control+C').
Without this option, typing 'Control+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', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_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. See *note encrypted-connection-options::.
'--syslog', '-j'
Command-Line Format
'--syslog'
This option causes *note 'mysql': mysql. to send interactive statements to the system logging facility. On Unix, this is 'syslog'; 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, see *note mysql-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'
Type
File name
Append a copy of output to the given file. This option works only in interactive mode. *note mysql-commands::, discusses tee files further.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-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', '-u USER_NAME'
Command-Line Format
'--user=user_name'
Type
String
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 ''.
'--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 with note 'mysql': mysql. matches that of note 'mysqldump': mysqldump. '--xml'. See *note mysqldump::, 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>
File: manual.info.tmp, Node: mysql-commands, Next: mysql-logging, Prev: mysql-command-options, Up: mysql
4.5.1.2 mysql Client Commands .............................
note 'mysql': mysql. sends each SQL statement that you issue to the server to be executed. There is also a set of commands that note 'mysql': mysql. itself interprets. For a list of these commands, type 'help' or '' at the 'mysql>' prompt:
mysql> help
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement.
connect (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit (\e) Edit command with $EDITOR.
ego (\G) Send command to mysql server, display result vertically.
exit (\q) Exit mysql. Same as quit.
go (\g) Send command to mysql server.
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.
notee (\t) Don't write into outfile.
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print (\p) Print current command.
prompt (\R) Change your mysql prompt.
quit (\q) Quit mysql.
rehash (\#) Rebuild completion hash.
source (\.) Execute an SQL script file. Takes a file name as an argument.
status (\s) Get status information from the server.
system (\!) Execute a system shell command.
tee (\T) Set outfile [to_outfile]. Append everything into given
outfile.
use (\u) Use another database. Takes database name as argument.
charset (\C) Switch to another charset. Might be needed for processing
binlog with multi-byte charsets.
warnings (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.
For server side help, type 'help contents'
If note 'mysql': mysql. is invoked with the '--binary-mode' option, all note 'mysql': mysql. commands are disabled except 'charset' and 'delimiter' in noninteractive mode (for input piped to *note 'mysql': mysql. or loaded using the 'source' command).
Each command has both a long and short form. The long form is not case-sensitive; the short form is. The long form can be followed by an optional semicolon terminator, but the short form should not.
The use of short-form commands within multiple-line '/* ... /' comments is not supported. Short-form commands do work within single-line '/! ... /' version comments, as do '/+ ... /' optimizer-hint comments, which are stored in object definitions. If there is a concern that optimizer-hint comments may be stored in object definitions so that dump files when reloaded with 'mysql' would result in execution of such commands, either invoke note 'mysql': mysql. with the '--binary-mode' option or use a reload client other than *note 'mysql': mysql.
'help [ARG]', '', '? [ARG]', '? [ARG]'
Display a help message listing the available *note 'mysql': mysql. commands.
If you provide an argument to the 'help' command, note 'mysql': mysql. uses it as a search string to access server-side help from the contents of the MySQL Reference Manual. For more information, see note mysql-server-side-help::.
'charset CHARSET_NAME', 'CHARSET_NAME'
Change the default character set and issue a note 'SET NAMES': set-names. statement. This enables the character set to remain synchronized on the client and server if note 'mysql': mysql. is run with auto-reconnect enabled (which is not recommended), because the specified character set is used for reconnects.
'clear', ''
Clear the current input. Use this if you change your mind about executing the statement that you are entering.
'connect [DB_NAME [HOST_NAME]]', ''
Reconnect to the server. The optional database name and host name arguments may be given to specify the default database or the host where the server is running. If omitted, the current values are used.
'delimiter STR', 'STR'
Change the string that *note 'mysql': mysql. interprets as the separator between SQL statements. The default is the semicolon character (';').
The delimiter string can be specified as an unquoted or quoted argument on the 'delimiter' command line. Quoting can be done with either single quote ('''), double quote ('"'), or backtick ('`') characters. To include a quote within a quoted string, either quote the string with a different quote character or escape the quote with a backslash ('') character. Backslash should be avoided outside of quoted strings because it is the escape character for MySQL. For an unquoted argument, the delimiter is read up to the first space or end of line. For a quoted argument, the delimiter is read up to the matching quote on the line.
note 'mysql': mysql. interprets instances of the delimiter string as a statement delimiter anywhere it occurs, except within quoted strings. Be careful about defining a delimiter that might occur within other words. For example, if you define the delimiter as 'X', it is not possible to use the word 'INDEX' in statements. note 'mysql': mysql. interprets this as 'INDE' followed by the delimiter 'X'.
When the delimiter recognized by note 'mysql': mysql. is set to something other than the default of ';', instances of that character are sent to the server without interpretation. However, the server itself still interprets ';' as a statement delimiter and processes statements accordingly. This behavior on the server side comes into play for multiple-statement execution (see Multiple Statement Execution Support (https://dev.mysql.com/doc/c-api/5.7/en/c-api-multiple-queries.html)), and for parsing the body of stored procedures and functions, triggers, and events (see note stored-programs-defining::).
'edit', ''
Edit the current input statement. *note 'mysql': mysql. checks the values of the 'EDITOR' and 'VISUAL' environment variables to determine which editor to use. The default editor is 'vi' if neither variable is set.
The 'edit' command works only in Unix.
'ego', ''
Send the current statement to the server to be executed and display the result using vertical format.
'exit', ''
Exit *note 'mysql': mysql.
'go', ''
Send the current statement to the server to be executed.
'nopager', ''
Disable output paging. See the description for 'pager'.
The 'nopager' command works only in Unix.
'notee', ''
Disable output copying to the tee file. See the description for 'tee'.
'nowarning', ''
Disable display of warnings after each statement.
'pager [COMMAND]', '[COMMAND]'
Enable output paging. By using the '--pager' option when you invoke note 'mysql': mysql, it is possible to browse or search query results in interactive mode with Unix programs such as 'less', 'more', or any other similar program. If you specify no value for the option, note 'mysql': mysql. checks the value of the 'PAGER' environment variable and sets the pager to that. Pager functionality works only in interactive mode.
Output paging can be enabled interactively with the 'pager' command and disabled with 'nopager'. The command takes an optional argument; if given, the paging program is set to that. With no argument, the pager is set to the pager that was set on the command line, or 'stdout' if no pager was specified.
Output paging works only in Unix because it uses the 'popen()' function, which does not exist on Windows. For Windows, the 'tee' option can be used instead to save query output, although it is not as convenient as 'pager' for browsing output in some situations.
'print', ''
Print the current input statement without executing it.
'prompt [STR]', ''
Reconfigure the *note 'mysql': mysql. prompt to the given string. The special character sequences that can be used in the prompt are described later in this section.
If you specify the 'prompt' command with no argument, *note 'mysql': mysql. resets the prompt to the default of 'mysql>'.
'quit', ''
Exit *note 'mysql': mysql.
'rehash', '#'
Rebuild the completion hash that enables database, table, and column name completion while you are entering statements. (See the description for the '--auto-rehash' option.)
'resetconnection', ''
Reset the connection to clear the session state.
Resetting a connection has effects similar to 'mysql_change_user()' (https://dev.mysql.com/doc/c-api/5.7/en/mysql-change-user.html) or an auto-reconnect except that the connection is not closed and reopened, and re-authentication is not done. See mysql_change_user() (https://dev.mysql.com/doc/c-api/5.7/en/mysql-change-user.html), and Automatic Reconnection Control (https://dev.mysql.com/doc/c-api/5.7/en/c-api-auto-reconnect.html).
This example shows how 'resetconnection' clears a value maintained in the session state:
mysql> SELECT LAST_INSERT_ID(3);
+-------------------+
| LAST_INSERT_ID(3) |
+-------------------+
| 3 |
+-------------------+
mysql> SELECT LAST_INSERT_ID();
+------------------+
| LAST_INSERT_ID() |
+------------------+
| 3 |
+------------------+
mysql> resetconnection;
mysql> SELECT LAST_INSERT_ID();
+------------------+
| LAST_INSERT_ID() |
+------------------+
| 0 |
+------------------+
'source FILE_NAME', '. FILE_NAME'
Read the named file and executes the statements contained therein. On Windows, specify path name separators as '/' or '\'.
Quote characters are taken as part of the file name itself. For best results, the name should not include space characters.
'status', ''
Provide status information about the connection and the server you are using. If you are running with '--safe-updates' enabled, 'status' also prints the values for the *note 'mysql': mysql. variables that affect your queries.
'system COMMAND', '! COMMAND'
Execute the given command using your default command interpreter.
The 'system' command works only in Unix.
'tee [FILE_NAME]', ''
By using the '--tee' option when you invoke note 'mysql': mysql, you can log statements and their output. All the data displayed on the screen is appended into a given file. This can be very useful for debugging purposes also. note 'mysql': mysql. flushes results to the file after each statement, just before it prints its next prompt. Tee functionality works only in interactive mode.
You can enable this feature interactively with the 'tee' command. Without a parameter, the previous file is used. The 'tee' file can be disabled with the 'notee' command. Executing 'tee' again re-enables logging.
'use DB_NAME', 'B_NAME'
Use DB_NAME as the default database.
'warnings', ''
Enable display of warnings after each statement (if there are any).
Here are a few tips about the 'pager' command:
You can use it to write to a file and the results go only to the file:
mysql> pager cat > /tmp/log.txt
You can also pass any options for the program that you want to use as your pager:
mysql> pager less -n -i -S
In the preceding example, note the '-S' option. You may find it very useful for browsing wide query results. Sometimes a very wide result set is difficult to read on the screen. The '-S' option to 'less' can make the result set much more readable because you can scroll it horizontally using the left-arrow and right-arrow keys. You can also use '-S' interactively within 'less' to switch the horizontal-browse mode on and off. For more information, read the 'less' manual page:
man less
The '-F' and '-X' options may be used with 'less' to cause it to exit if output fits on one screen, which is convenient when no scrolling is necessary:
mysql> pager less -n -i -S -F -X
You can specify very complex pager commands for handling query output:
mysql> pager cat | tee /dr1/tmp/res.txt \
| tee /dr2/tmp/res2.txt | less -n -i -S
In this example, the command would send query results to two files in two different directories on two different file systems mounted on '/dr1' and '/dr2', yet still display the results onscreen using 'less'.
You can also combine the 'tee' and 'pager' functions. Have a 'tee' file enabled and 'pager' set to 'less', and you are able to browse the results using the 'less' program and still have everything appended into a file the same time. The difference between the Unix 'tee' used with the 'pager' command and the note 'mysql': mysql. built-in 'tee' command is that the built-in 'tee' works even if you do not have the Unix 'tee' available. The built-in 'tee' also logs everything that is printed on the screen, whereas the Unix 'tee' used with 'pager' does not log quite that much. Additionally, 'tee' file logging can be turned on and off interactively from within note 'mysql': mysql. This is useful when you want to log some queries to a file, but not others.
The 'prompt' command reconfigures the default 'mysql>' prompt. The string for defining the prompt can contain the following special sequences.
Option Description
'' The current connection identifier
'' A counter that increments for each statement you issue
'' The full current date
'' The default database
'' The server host
'' The current delimiter
'' Minutes of the current time
'' A newline character
'' The current month in three-letter format (Jan, Feb, ...)
'' The current month in numeric format
'' am/pm
'' The current TCP/IP port or socket file
'' The current time, in 24-hour military time (0-23)
'' The current time, standard 12-hour time (1-12)
'' Semicolon
'' Seconds of the current time
'' A tab character
''
Your full 'USER_NAME@HOST_NAME' account name
'' Your user name
'' The server version
'' The current day of the week in three-letter format (Mon, Tue, ...)
'' The current year, four digits
'' The current year, two digits
'_' A space
' ' A space (a space follows the backslash)
''' Single quote
'"' Double quote
'\' A literal '' backslash character
''
X, for any 'X' not listed above
You can set the prompt in several ways:
Use an environment variable. You can set the 'MYSQL_PS1' environment variable to a prompt string. For example:
export MYSQL_PS1="(\u@\h) [\d]> "
Use a command-line option. You can set the '--prompt' option on the command line to *note 'mysql': mysql. For example:
$> mysql --prompt="(\u@\h) [\d]> "
(user@host) [database]>
Use an option file. You can set the 'prompt' option in the '[mysql]' group of any MySQL option file, such as '/etc/my.cnf' or the '.my.cnf' file in your home directory. For example:
[mysql]
prompt=(\\u@\\h) [\\d]>\\_
In this example, note that the backslashes are doubled. If you set the prompt using the 'prompt' option in an option file, it is advisable to double the backslashes when using the special prompt options. There is some overlap in the set of permissible prompt options and the set of special escape sequences that are recognized in option files. (The rules for escape sequences in option files are listed in *note option-files::.) The overlap may cause you problems if you use single backslashes. For example, '' is interpreted as a space rather than as the current seconds value. The following example shows how to define a prompt within an option file to include the current time in 'HH:MM:SS>' format:
[mysql]
prompt="\\r:\\m:\\s> "
Set the prompt interactively. You can change your prompt interactively by using the 'prompt' (or '') command. For example:
mysql> prompt (\u@\h) [\d]>\_
PROMPT set to '(\u@\h) [\d]>\_'
(USER@HOST) [DATABASE]>
(USER@HOST) [DATABASE]> prompt
Returning to default PROMPT of mysql>
mysql>
File: manual.info.tmp, Node: mysql-logging, Next: mysql-server-side-help, Prev: mysql-commands, Up: mysql
4.5.1.3 mysql Client Logging ............................
The *note 'mysql': mysql. client can do these types of logging for statements executed interactively:
On Unix, *note 'mysql': mysql. writes the statements to a history file. By default, this file is named '.mysql_history' in your home directory. To specify a different file, set the value of the 'MYSQL_HISTFILE' environment variable.
On all platforms, if the '--syslog' option is given, *note 'mysql': mysql. writes the statements to the system logging facility. On Unix, this is 'syslog'; 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.
The following discussion describes characteristics that apply to all logging types and provides information specific to each logging type.
*note mysql-logging-how-logging-occurs::
*note mysql-logging-history-file::
*note mysql-logging-syslog::
How Logging Occurs
For each enabled logging destination, statement logging occurs as follows:
Statements are logged only when executed interactively. Statements are noninteractive, for example, when read from a file or a pipe. It is also possible to suppress statement logging by using the '--batch' or '--execute' option.
Statements are ignored and not logged if they match any pattern in the 'ignore' list. This list is described later.
*note 'mysql': mysql. logs each nonignored, nonempty statement line individually.
If a nonignored statement spans multiple lines (not including the terminating delimiter), *note 'mysql': mysql. concatenates the lines to form the complete statement, maps newlines to spaces, and logs the result, plus a delimiter.
Consequently, an input statement that spans multiple lines can be logged twice. Consider this input:
mysql> SELECT
-> 'Today is'
-> ,
-> CURDATE()
-> ;
In this case, *note 'mysql': mysql. logs the 'SELECT', ''Today is'', ',', 'CURDATE()', and ';' lines as it reads them. It also logs the complete statement, after mapping 'SELECT'Today is',()' to 'SELECT 'Today is' , CURDATE()', plus a delimiter. Thus, these lines appear in logged output:
SELECT
'Today is'
,
CURDATE()
;
SELECT 'Today is' , CURDATE();
note 'mysql': mysql. ignores for logging purposes statements that match any pattern in the 'ignore' list. By default, the pattern list is '"IDENTIFIED:PASSWORD*"', to ignore statements that refer to passwords. Pattern matching is not case-sensitive. Within patterns, two characters are special:
'?' matches any single character.
'*' matches any sequence of zero or more characters.
To specify additional patterns, use the '--histignore' option or set the 'MYSQL_HISTIGNORE' environment variable. (If both are specified, the option value takes precedence.) The value should be a list of one or more colon-separated patterns, which are appended to the default pattern list.
Patterns specified on the command line might need to be quoted or escaped to prevent your command interpreter from treating them specially. For example, to suppress logging for 'UPDATE' and 'DELETE' statements in addition to statements that refer to passwords, invoke *note 'mysql': mysql. like this:
mysql --histignore="*UPDATE*:*DELETE*"
Controlling the History File
The '.mysql_history' file should be protected with a restrictive access mode because sensitive information might be written to it, such as the text of SQL statements that contain passwords. See note password-security-user::. Statements in the file are accessible from the note 'mysql': mysql. client when the 'up-arrow' key is used to recall the history. See *note mysql-history::.
If you do not want to maintain a history file, first remove '.mysql_history' if it exists. Then use either of the following techniques to prevent it from being created again:
Set the 'MYSQL_HISTFILE' environment variable to '/dev/null'. To cause this setting to take effect each time you log in, put it in one of your shell's startup files.
Create '.mysql_history' as a symbolic link to '/dev/null'; this need be done only once:
ln -s /dev/null $HOME/.mysql_history
syslog Logging Characteristics
If the '--syslog' option is given, *note 'mysql': mysql. writes interactive statements to the system logging facility. Message logging has the following characteristics.
Logging occurs at the 'information' level. This corresponds to the 'LOG_INFO' priority for 'syslog' on Unix/Linux 'syslog' capability and to 'EVENTLOG_INFORMATION_TYPE' for the Windows Event Log. Consult your system documentation for configuration of your logging capability.
Message size is limited to 1024 bytes.
Messages consist of the identifier 'MysqlClient' followed by these values:
'SYSTEM_USER'
The operating system user name (login name) or '--' if the user is unknown.
'MYSQL_USER'
The MySQL user name (specified with the '--user' option) or '--' if the user is unknown.
'CONNECTION_ID':
The client connection identifier. This is the same as the 'CONNECTION_ID()' function value within the session.
'DB_SERVER'
The server host or '--' if the host is unknown.
'DB'
The default database or '--' if no database has been selected.
'QUERY'
The text of the logged statement.
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;'
File: manual.info.tmp, Node: mysql-server-side-help, Next: mysql-batch-commands, Prev: mysql-logging, Up: mysql
4.5.1.4 mysql Client Server-Side Help .....................................
mysql> help SEARCH_STRING
If you provide an argument to the 'help' command, note 'mysql': mysql. uses it as a search string to access server-side help from the contents of the MySQL Reference Manual. The proper operation of this command requires that the help tables in the 'mysql' database be initialized with help topic information (see note server-side-help-support::).
If there is no match for the search string, the search fails:
mysql> help me
Nothing found
Please try to run 'help contents' for a list of all accessible topics
Use *note 'help contents': help. to see a list of the help categories:
mysql> help contents
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the
following categories:
Account Management
Administration
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Language Structure
Plugins
Storage Engines
Stored Routines
Table Maintenance
Transactions
Triggers
If the search string matches multiple items, *note 'mysql': mysql. shows a list of matching topics:
mysql> help logs
Many help items for your request exist.
To make a more specific request, please type 'help <item>',
where <item> is one of the following topics:
SHOW
SHOW BINARY LOGS
SHOW ENGINE
SHOW LOGS
Use a topic as the search string to see the help entry for that topic:
mysql> help show binary logs
Name: 'SHOW BINARY LOGS'
Description:
Syntax:
SHOW BINARY LOGS
SHOW MASTER LOGS
Lists the binary log files on the server. This statement is used as
part of the procedure described in [purge-binary-logs], that shows how
to determine which logs can be purged.
mysql> SHOW BINARY LOGS;
+---------------+-----------+
| Log_name | File_size |
+---------------+-----------+
| binlog.000015 | 724935 |
| binlog.000016 | 733481 |
+---------------+-----------+
The search string can contain the wildcard characters '%' and '_'. These have the same meaning as for pattern-matching operations performed with the 'LIKE' operator. For example, 'HELP rep%' returns a list of topics that begin with 'rep':
mysql> HELP rep%
Many help items for your request exist.
To make a more specific request, please type 'help <item>',
where <item> is one of the following
topics:
REPAIR TABLE
REPEAT FUNCTION
REPEAT LOOP
REPLACE
REPLACE FUNCTION
File: manual.info.tmp, Node: mysql-batch-commands, Next: mysql-tips, Prev: mysql-server-side-help, Up: mysql
4.5.1.5 Executing SQL Statements from a Text File .................................................
The *note 'mysql': mysql. client typically is used interactively, like this:
mysql DB_NAME
However, it is also possible to put your SQL statements in a file and then tell note 'mysql': mysql. to read its input from that file. To do so, create a text file TEXT_FILE that contains the statements you wish to execute. Then invoke note 'mysql': mysql. as shown here:
mysql DB_NAME < TEXT_FILE
If you place a 'USE DB_NAME' statement as the first statement in the file, it is unnecessary to specify the database name on the command line:
mysql < text_file
If you are already running *note 'mysql': mysql, you can execute an SQL script file using the 'source' command or '.' command:
mysql> source FILE_NAME
mysql> \. FILE_NAME
Sometimes you may want your script to display progress information to the user. For this you can insert statements like this:
SELECT '<info_to_display>' AS ' ';
The statement shown outputs '
You can also invoke *note 'mysql': mysql. with the '--verbose' option, which causes each statement to be displayed before the result that it produces.
note 'mysql': mysql. ignores Unicode byte order mark (BOM) characters at the beginning of input files. Previously, it read them and sent them to the server, resulting in a syntax error. Presence of a BOM does not cause note 'mysql': mysql. to change its default character set. To do that, invoke *note 'mysql': mysql. with an option such as '--default-character-set=utf8'.
For more information about batch mode, see *note batch-mode::.
File: manual.info.tmp, Node: mysql-tips, Prev: mysql-batch-commands, Up: mysql
4.5.1.6 mysql Client Tips .........................
This section provides information about techniques for more effective use of note 'mysql': mysql. and about note 'mysql': mysql. operational behavior.
*note mysql-input-editing::
*note mysql-history::
*note windows-unicode-support::
*note vertical-query-results::
*note safe-updates::
*note mysql-reconnect::
*note mysql-parsers::
Input-Line Editing
*note 'mysql': mysql. supports input-line editing, which enables you to modify the current input line in place or recall previous input lines. For example, the 'left-arrow' and 'right-arrow' keys move horizontally within the current input line, and the 'up-arrow' and 'down-arrow' keys move up and down through the set of previously entered lines. 'Backspace' deletes the character before the cursor and typing new characters enters them at the cursor position. To enter the line, press 'Enter'.
On Windows, the editing key sequences are the same as supported for command editing in console windows. On Unix, the key sequences depend on the input library used to build *note 'mysql': mysql. (for example, the 'libedit' or 'readline' library).
Documentation for the 'libedit' and 'readline' libraries is available online. To change the set of key sequences permitted by a given input library, define key bindings in the library startup file. This is a file in your home directory: '.editrc' for 'libedit' and '.inputrc' for 'readline'.
For example, in 'libedit', 'Control+W' deletes everything before the current cursor position and 'Control+U' deletes the entire line. In 'readline', 'Control+W' deletes the word before the cursor and 'Control+U' deletes everything before the current cursor position. If *note 'mysql': mysql. was built using 'libedit', a user who prefers the 'readline' behavior for these two keys can put the following lines in the '.editrc' file (creating the file if necessary):
bind "^W" ed-delete-prev-word
bind "^U" vi-kill-line-prev
To see the current set of key bindings, temporarily put a line that says only 'bind' at the end of '.editrc'. Then *note 'mysql': mysql. shows the bindings when it starts.
Disabling Interactive History
The 'up-arrow' key enables you to recall input lines from current and previous sessions. In cases where a console is shared, this behavior may be unsuitable. *note 'mysql': mysql. supports disabling the interactive history partially or fully, depending on the host platform.
On Windows, the history is stored in memory. 'Alt+F7' deletes all input lines stored in memory for the current history buffer. It also deletes the list of sequential numbers in front of the input lines displayed with 'F7' and recalled (by number) with 'F9'. New input lines entered after you press 'Alt+F7' repopulate the current history buffer. Clearing the buffer does not prevent logging to the Windows Event Viewer, if the '--syslog' option was used to start *note 'mysql': mysql. Closing the console window also clears the current history buffer.
To disable interactive history on Unix, first delete the '.mysql_history' file, if it exists (previous entries are recalled otherwise). Then start note 'mysql': mysql. with the '--histignore=""' option to ignore all new input lines. To re-enable the recall (and logging) behavior, restart *note 'mysql': mysql. without the option.
If you prevent the '.mysql_history' file from being created (see note mysql-logging-history-file::) and use '--histignore=""' to start the *note 'mysql': mysql. client, the interactive history recall facility is disabled fully. Alternatively, if you omit the '--histignore' option, you can recall the input lines entered during the current session.
Unicode Support on Windows
Windows provides APIs based on UTF-16LE for reading from and writing to the console; the note 'mysql': mysql. client for Windows is able to use these APIs. The Windows installer creates an item in the MySQL menu named 'MySQL command line client - Unicode'. This item invokes the note 'mysql': mysql. client with properties set to communicate through the console to the MySQL server using Unicode.
To take advantage of this support manually, run *note 'mysql': mysql. within a console that uses a compatible Unicode font and set the default character set to a Unicode character set that is supported for communication with the server:
Open a console window.
Go to the console window properties, select the font tab, and choose Lucida Console or some other compatible Unicode font. This is necessary because console windows start by default using a DOS raster font that is inadequate for Unicode.
Execute note 'mysql.exe': mysql. with the '--default-character-set=utf8' (or 'utf8mb4') option. This option is necessary because 'utf16le' is one of the character sets that cannot be used as the client character set. See note charset-connection-impermissible-client-charset::.
With those changes, *note 'mysql': mysql. can use the Windows APIs to communicate with the console using UTF-16LE, and communicate with the server using UTF-8. (The menu item mentioned previously sets the font and character set as just described.)
To avoid those steps each time you run note 'mysql': mysql, you can create a shortcut that invokes note 'mysql.exe': mysql. The shortcut should set the console font to Lucida Console or some other compatible Unicode font, and pass the '--default-character-set=utf8' (or 'utf8mb4') option to *note 'mysql.exe': mysql.
Alternatively, create a shortcut that only sets the console font, and set the character set in the '[mysql]' group of your 'my.ini' file:
[mysql]
default-character-set=utf8
Displaying Query Results Vertically
Some query results are much more readable when displayed vertically, instead of in the usual horizontal table format. Queries can be displayed vertically by terminating the query with instead of a semicolon. For example, longer text values that include newlines often are much easier to read with vertical output:
mysql> SELECT * FROM mails WHERE LENGTH(txt) < 300 LIMIT 300,1\G
*************************** 1. row ***************************
msg_nro: 3068
date: 2000-03-01 23:29:50
time_zone: +0200
mail_from: Jones
reply: jones@example.com
mail_to: "John Smith" <smith@example.com>
sbj: UTF-8
txt: >>>>> "John" == John Smith writes:
John> Hi. I think this is a good idea. Is anyone familiar
John> with UTF-8 or Unicode? Otherwise, I'll put this on my
John> TODO list and see what happens.
Yes, please do that.
Regards,
Jones
file: inbox-jani-1
hash: 190402944
1 row in set (0.09 sec)
Using Safe-Updates Mode (-safe-updates)
For beginners, a useful startup option is '--safe-updates' (or '--i-am-a-dummy', which has the same effect). Safe-updates mode is helpful for cases when you might have issued an note 'UPDATE': update. or note 'DELETE': delete. statement but forgotten the 'WHERE' clause indicating which rows to modify. Normally, such statements update or delete all rows in the table. With '--safe-updates', you can modify rows only by specifying the key values that identify them, or a 'LIMIT' clause, or both. This helps prevent accidents. Safe-updates mode also restricts *note 'SELECT': select. statements that produce (or are estimated to produce) very large result sets.
The '--safe-updates' option causes *note 'mysql': mysql. to execute the following statement when it connects to the MySQL server, to set the session values of the 'sql_safe_updates', 'sql_select_limit', and 'max_join_size' system variables:
SET sql_safe_updates=1, sql_select_limit=1000, max_join_size=1000000;
The *note 'SET': set-variable. statement affects statement processing as follows:
Enabling 'sql_safe_updates' causes note 'UPDATE': update. and note 'DELETE': delete. statements to produce an error if they do not specify a key constraint in the 'WHERE' clause, or provide a 'LIMIT' clause, or both. For example:
UPDATE TBL_NAME SET NOT_KEY_COLUMN=VAL WHERE KEY_COLUMN=VAL;
UPDATE TBL_NAME SET NOT_KEY_COLUMN=VAL LIMIT 1;
Setting 'sql_select_limit' to 1,000 causes the server to limit all *note 'SELECT': select. result sets to 1,000 rows unless the statement includes a 'LIMIT' clause.
Setting 'max_join_size' to 1,000,000 causes multiple-table *note 'SELECT': select. statements to produce an error if the server estimates it must examine more than 1,000,000 row combinations.
To specify result set limits different from 1,000 and 1,000,000, you can override the defaults by using the '--select-limit' and '--max-join-size' options when you invoke *note 'mysql': mysql.:
mysql --safe-updates --select-limit=500 --max-join-size=10000
It is possible for note 'UPDATE': update. and note 'DELETE': delete. statements to produce an error in safe-updates mode even with a key specified in the 'WHERE' clause, if the optimizer decides not to use the index on the key column:
Range access on the index cannot be used if memory usage exceeds that permitted by the 'range_optimizer_max_mem_size' system variable. The optimizer then falls back to a table scan. See *note range-optimization-memory-use::.
If key comparisons require type conversion, the index may not be used (see note mysql-indexes::). Suppose that an indexed string column 'c1' is compared to a numeric value using 'WHERE c1 = 2222'. For such comparisons, the string value is converted to a number and the operands are compared numerically (see note type-conversion::), preventing use of the index. If safe-updates mode is enabled, an error occurs.
As of MySQL 5.7.25, safe-updates mode also includes these behaviors:
note 'EXPLAIN': explain. with note 'UPDATE': update. and note 'DELETE': delete. statements does not produce safe-updates errors. This enables use of note 'EXPLAIN': explain. plus *note 'SHOW WARNINGS': show-warnings. to see why an index is not used, which can be helpful in cases such as when a 'range_optimizer_max_mem_size' violation or type conversion occurs and the optimizer does not use an index even though a key column was specified in the 'WHERE' clause.
When a safe-updates error occurs, the error message includes the first diagnostic that was produced, to provide information about the reason for failure. For example, the message may indicate that the 'range_optimizer_max_mem_size' value was exceeded or type conversion occurred, either of which can preclude use of an index.
For multiple-table deletes and updates, an error is produced with safe updates enabled only if any target table uses a table scan.
Disabling mysql Auto-Reconnect
If the note 'mysql': mysql. client loses its connection to the server while sending a statement, it immediately and automatically tries to reconnect once to the server and send the statement again. However, even if note 'mysql': mysql. succeeds in reconnecting, your first connection has ended and all your previous session objects and settings are lost: temporary tables, the autocommit mode, and user-defined and session variables. Also, any current transaction rolls back. This behavior may be dangerous for you, as in the following example where the server was shut down and restarted between the first and second statements without you knowing it:
mysql> SET @a=1;
Query OK, 0 rows affected (0.05 sec)
mysql> INSERT INTO t VALUES(@a);
ERROR 2006: MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 1
Current database: test
Query OK, 1 row affected (1.30 sec)
mysql> SELECT * FROM t;
+------+
| a |
+------+
| NULL |
+------+
1 row in set (0.05 sec)
The '@a' user variable has been lost with the connection, and after the reconnection it is undefined. If it is important to have note 'mysql': mysql. terminate with an error if the connection has been lost, you can start the note 'mysql': mysql. client with the '--skip-reconnect' option.
For more information about auto-reconnect and its effect on state information when a reconnection occurs, see Automatic Reconnection Control (https://dev.mysql.com/doc/c-api/5.7/en/c-api-auto-reconnect.html).
mysql Client Parser Versus Server Parser
The note 'mysql': mysql. client uses a parser on the client side that is not a duplicate of the complete parser used by the note 'mysqld': mysqld. server on the server side. This can lead to differences in treatment of certain constructs. Examples:
The server parser treats strings delimited by '"' characters as identifiers rather than as plain strings if the 'ANSI_QUOTES' SQL mode is enabled.
The *note 'mysql': mysql. client parser does not take the 'ANSI_QUOTES' SQL mode into account. It treats strings delimited by '"', ''', and '`' characters the same, regardless of whether 'ANSI_QUOTES' is enabled.
Within '/! ... /' comments, the note 'mysql': mysql. client parser interprets short-form note 'mysql': mysql. commands. The server parser does not interpret them because these commands have no meaning on the server side.
If it is desirable for note 'mysql': mysql. not to interpret short-form commands within comments, a partial workaround is to use the '--binary-mode' option, which causes all note 'mysql': mysql. commands to be disabled except '' and '' in noninteractive mode (for input piped to *note 'mysql': mysql. or loaded using the 'source' command).
File: manual.info.tmp, Node: mysqladmin, Next: mysqlcheck, Prev: mysql, Up: programs-client
*note 'mysqladmin': mysqladmin. is a client for performing administrative operations. You can use it to check the server's configuration and current status, to create and drop databases, and more.
Invoke *note 'mysqladmin': mysqladmin. like this:
mysqladmin [OPTIONS] COMMAND [COMMAND-ARG] [COMMAND [COMMAND-ARG]] ...
*note 'mysqladmin': mysqladmin. supports the following commands. Some of the commands take an argument following the command name.
'create DB_NAME'
Create a new database named DB_NAME.
'debug'
Tell the server to write debug information to the error log. The connected user must have the 'SUPER' privilege. Format and content of this information is subject to change.
This includes information about the Event Scheduler. See *note events-status-info::.
'drop DB_NAME'
Delete the database named DB_NAME and all its tables.
'extended-status'
Display the server status variables and their values.
'flush-hosts'
Flush all information in the host cache. See *note host-cache::.
'flush-logs [LOG_TYPE ...]'
Flush all logs.
The *note 'mysqladmin flush-logs': mysqladmin. command permits optional log types to be given, to specify which logs to flush. Following the 'flush-logs' command, you can provide a space-separated list of one or more of the following log types: 'binary', 'engine', 'error', 'general', 'relay', 'slow'. These correspond to the log types that can be specified for the 'FLUSH LOGS' SQL statement.
'flush-privileges'
Reload the grant tables (same as 'reload').
'flush-status'
Clear status variables.
'flush-tables'
Flush all tables.
'flush-threads'
Flush the thread cache.
'kill ID,ID,...'
Kill server threads. If multiple thread ID values are given, there must be no spaces in the list.
To kill threads belonging to other users, the connected user must have the 'SUPER' privilege.
'old-password NEW_PASSWORD'
This is like the 'password' command but stores the password using the old (pre-4.1) password-hashing format. (See *note password-hashing::.)
This command was removed in MySQL 5.7.5.
'password NEW_PASSWORD'
Set a new password. This changes the password to NEW_PASSWORD for the account that you use with note 'mysqladmin': mysqladmin. for connecting to the server. Thus, the next time you invoke note 'mysqladmin': mysqladmin. (or any other client program) using the same account, you must specify the new password.
Warning:
Setting a password using *note 'mysqladmin': mysqladmin. should be considered insecure. On some systems, your password becomes visible to system status programs such as 'ps' that may be invoked by other users to display command lines. MySQL clients typically overwrite the command-line password argument with zeros during their initialization sequence. However, there is still a brief interval during which the value is visible. Also, on some systems this overwriting strategy is ineffective and the password remains visible to 'ps'. (SystemV Unix systems and perhaps others are subject to this problem.)
If the NEW_PASSWORD value contains spaces or other characters that are special to your command interpreter, you need to enclose it within quotation marks. On Windows, be sure to use double quotation marks rather than single quotation marks; single quotation marks are not stripped from the password, but rather are interpreted as part of the password. For example:
mysqladmin password "my new password"
The new password can be omitted following the 'password' command. In this case, note 'mysqladmin': mysqladmin. prompts for the password value, which enables you to avoid specifying the password on the command line. Omitting the password value should be done only if 'password' is the final command on the note 'mysqladmin': mysqladmin. command line. Otherwise, the next argument is taken as the password.
Caution:
Do not use this command used if the server was started with the '--skip-grant-tables' option. No password change is applied. This is true even if you precede the 'password' command with 'flush-privileges' on the same command line to re-enable the grant tables because the flush operation occurs after you connect. However, you can use note 'mysqladmin flush-privileges': mysqladmin. to re-enable the grant table and then use a separate note 'mysqladmin password': mysqladmin. command to change the password.
'ping'
Check whether the server is available. The return status from *note 'mysqladmin': mysqladmin. is 0 if the server is running, 1 if it is not. This is 0 even in case of an error such as 'Access denied', because this means that the server is running but refused the connection, which is different from the server not running.
'processlist'
Show a list of active server threads. This is like the output of the note 'SHOW PROCESSLIST': show-processlist. statement. If the '--verbose' option is given, the output is like that of note 'SHOW FULL PROCESSLIST': show-processlist. (See *note show-processlist::.)
'reload'
Reload the grant tables.
'refresh'
Flush all tables and close and open log files.
'shutdown'
Stop the server.
'start-slave'
Start replication on a replica server.
'status'
Display a short server status message.
'stop-slave'
Stop replication on a replica server.
'variables'
Display the server system variables and their values.
'version'
Display version information from the server.
All commands can be shortened to any unique prefix. For example:
$> mysqladmin proc stat
+----+-------+-----------+----+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------+-----------+----+---------+------+-------+------------------+
| 51 | jones | localhost | | Query | 0 | | show processlist |
+----+-------+-----------+----+---------+------+-------+------------------+
Uptime: 1473624 Threads: 1 Questions: 39487
Slow queries: 0 Opens: 541 Flush tables: 1
Open tables: 19 Queries per second avg: 0.0268
The *note 'mysqladmin status': mysqladmin. command result displays the following values:
'Uptime'
The number of seconds the MySQL server has been running.
'Threads'
The number of active threads (clients).
'Questions'
The number of questions (queries) from clients since the server was started.
'Slow queries'
The number of queries that have taken more than 'long_query_time' seconds. See *note slow-query-log::.
'Opens'
The number of tables the server has opened.
'Flush tables'
The number of 'flush-*', 'refresh', and 'reload' commands the server has executed.
'Open tables'
The number of tables that currently are open.
If you execute note 'mysqladmin shutdown': mysqladmin. when connecting to a local server using a Unix socket file, note 'mysqladmin': mysqladmin. waits until the server's process ID file has been removed, to ensure that the server has stopped properly.
note 'mysqladmin': mysqladmin. supports the following options, which can be specified on the command line or in the '[mysqladmin]' and '[client]' groups of an option file. For information about option files used by MySQL programs, see note option-files::.
mysqladmin Options
Option Name Description IntroducedDeprecated
-bind-address
Use specified network interface to connect to MySQL Server
-character-sets-dir
Directory where character sets can be found
-compress
Compress all information sent between client and server
-connect-timeout
Number of seconds before connection timeout
-count
Number of iterations to make for repeated command execution
-debug
Write debugging log
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-default-character-set
Specify default character set
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-enable-cleartext-plugin
Enable cleartext authentication plugin
-force
Continue even if an SQL error occurs
-get-server-public-key
Request RSA 5.7.23 public key from
server
-help
Display help message and exit
-host
Host on which MySQL server is located
-login-path
Read login path options from .mylogin.cnf
-no-beep
Do not beep when errors occur
-no-defaults
Read no option files
-password
Password to use when connecting to server
-pipe
Connect to server using named pipe (Windows only)
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-print-defaults
Print default options
-protocol
Transport protocol to use
-relative
Show the difference between the current and previous values when used with the -sleep option
-secure-auth
Do not send Yes passwords to
server in old (pre-4.1) format
-server-public-key-path
Path name to file 5.7.23 containing RSA
public key
-shared-memory-base-name
Shared-memory name for shared-memory connections (Windows only)
-show-warnings
Show warnings after statement execution
-shutdown-timeout
The maximum number of seconds to wait for server shutdown
-silent
Silent mode
-sleep
Execute commands repeatedly, sleeping for delay seconds in between
-socket
Unix socket file or Windows named pipe to use
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of
connection to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-user
MySQL user name to use when connecting to server
-verbose
Verbose mode
-version
Display version information and exit
-vertical
Print query output rows vertically (one line per column value)
-wait
If the connection cannot be established, wait and retry instead of aborting
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--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=path'
Type
String
Default Value
'[none]'
The directory where character sets are installed. See *note charset-configuration::.
'--compress', '-C'
Command-Line Format
'--compress[={OFF|ON}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note connection-compression-control::.
'--connect-timeout=VALUE'
Command-Line Format
'--connect-timeout=value'
Type
Numeric
Default Value
'43200'
The maximum number of seconds before connection timeout. The default value is 43200 (12 hours).
'--count=N', '-c N'
Command-Line Format
'--count=#'
The number of iterations to make for repeated command execution if the '--sleep' option is given.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:o,/tmp/mysqladmin.trace'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default is 'd:t:o,/tmp/mysqladmin.trace'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--default-character-set=CHARSET_NAME'
Command-Line Format
'--default-character-set=charset_name'
Type
String
Use CHARSET_NAME as the default character set. See *note charset-configuration::.
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysqladmin': mysqladmin. normally reads the '[client]' and '[mysqladmin]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysqladmin': mysqladmin. also reads the '[client_other]' and '[mysqladmin_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--enable-cleartext-plugin'
Command-Line Format
'--enable-cleartext-plugin'
Type
Boolean
Default Value
'FALSE'
Enable the 'mysql_clear_password' cleartext authentication plugin. (See *note cleartext-pluggable-authentication::.)
'--force', '-f'
Command-Line Format
'--force'
Do not ask for confirmation for the 'drop DB_NAME' command. With multiple commands, continue even if an error occurs.
'--get-server-public-key'
Command-Line Format
'--get-server-public-key'
Introduced
5.7.23
Type
Boolean
Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the 'caching_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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host=host_name'
Type
String
Default Value
'localhost'
Connect to the MySQL server on the given host.
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--no-beep', '-b'
Command-Line Format
'--no-beep'
Suppress the warning beep that is emitted by default for errors such as a failure to connect to the server.
'--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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysqladmin': mysqladmin. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysqladmin': mysqladmin. should not prompt for one, use the '--skip-password' option.
'--pipe', '-W'
Command-Line Format
'--pipe'
Type
String
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the 'named_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 the 'named_pipe_full_access_group' system variable.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysqladmin': mysqladmin. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
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, see *note option-file-options::.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note transport-protocols::.
'--relative', '-r'
Command-Line Format
'--relative'
Show the difference between the current and previous values when used with the '--sleep' option. This option works only with the 'extended-status' command.
'--show-warnings'
Command-Line Format
'--show-warnings'
Show warnings resulting from execution of statements sent to the server.
'--secure-auth'
Command-Line Format
'--secure-auth'
Deprecated
Yes
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, see *note account-upgrades::.
'--server-public-key-path=FILE_NAME'
Command-Line Format
'--server-public-key-path=file_name'
Introduced
5.7.23
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
The '--server-public-key-path' option was added in MySQL 5.7.23.
'--shared-memory-base-name=NAME'
Command-Line Format
'--shared-memory-base-name=name'
Platform Specific
Windows
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 'MYSQL'. The shared-memory name is case-sensitive.
This option applies only if the server was started with the 'shared_memory' system variable enabled to support shared-memory connections.
'--shutdown-timeout=VALUE'
Command-Line Format
'--shutdown-timeout=seconds'
Type
Numeric
Default Value
'3600'
The maximum number of seconds to wait for server shutdown. The default value is 3600 (1 hour).
'--silent', '-s'
Command-Line Format
'--silent'
Exit silently if a connection to the server cannot be established.
'--sleep=DELAY', '-i DELAY'
Command-Line Format
'--sleep=delay'
Execute commands repeatedly, sleeping for DELAY seconds in between. The '--count' option determines the number of iterations. If '--count' is not given, *note 'mysqladmin': mysqladmin. executes commands indefinitely until interrupted.
'--socket=PATH', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_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. See *note encrypted-connection-options::.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-ciphers::.
This option was added in MySQL 5.7.10.
'--user=USER_NAME', '-u USER_NAME'
Command-Line Format
'--user=user_name,'
Type
String
The user name of the MySQL account to use for connecting to the server.
'--verbose', '-v'
Command-Line Format
'--verbose'
Verbose mode. Print more information about what the program does.
'--version', '-V'
Command-Line Format
'--version'
Display version information and exit.
'--vertical', '-E'
Command-Line Format
'--vertical'
Print output vertically. This is similar to '--relative', but prints output vertically.
'--wait[=COUNT]', '-w[COUNT]'
Command-Line Format
'--wait'
If the connection cannot be established, wait and retry instead of aborting. If a COUNT value is given, it indicates the number of times to retry. The default is one time.
File: manual.info.tmp, Node: mysqlcheck, Next: mysqldump, Prev: mysqladmin, Up: programs-client
The *note 'mysqlcheck': mysqlcheck. client performs table maintenance: It checks, repairs, optimizes, or analyzes tables.
Each table is locked and therefore unavailable to other sessions while it is being processed, although for check operations, the table is locked with a 'READ' lock only (see note lock-tables::, for more information about 'READ' and 'WRITE' locks). Table maintenance operations can be time-consuming, particularly for large tables. If you use the '--databases' or '--all-databases' option to process all tables in one or more databases, an invocation of note 'mysqlcheck': mysqlcheck. might take a long time. (This is also true for the MySQL upgrade procedure if it determines that table checking is needed because it processes tables the same way.)
note 'mysqlcheck': mysqlcheck. must be used when the note 'mysqld': mysqld. server is running, which means that you do not have to stop the server to perform table maintenance.
note 'mysqlcheck': mysqlcheck. uses the SQL statements note 'CHECK TABLE': check-table, note 'REPAIR TABLE': repair-table, note 'ANALYZE TABLE': analyze-table, and note 'OPTIMIZE TABLE': optimize-table. in a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the statements to the server to be executed. For details about which storage engines each statement works with, see the descriptions for those statements in note table-maintenance-statements::.
All storage engines do not necessarily support all four maintenance operations. In such cases, an error message is displayed. For example, if 'test.t' is an 'MEMORY' table, an attempt to check it produces this result:
$> mysqlcheck test t
test.t
note : The storage engine for the table doesn't support check
If note 'mysqlcheck': mysqlcheck. is unable to repair a table, see note rebuilding-tables:: for manual table repair strategies. This is the case, for example, for 'InnoDB' tables, which can be checked with note 'CHECK TABLE': check-table, but not repaired with note 'REPAIR TABLE': repair-table.
Caution:
It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to file system errors.
There are three general ways to invoke *note 'mysqlcheck': mysqlcheck.:
mysqlcheck [OPTIONS] DB_NAME [TBL_NAME ...]
mysqlcheck [OPTIONS] --databases DB_NAME ...
mysqlcheck [OPTIONS] --all-databases
If you do not name any tables following DB_NAME or if you use the '--databases' or '--all-databases' option, entire databases are checked.
note 'mysqlcheck': mysqlcheck. has a special feature compared to other client programs. The default behavior of checking tables ('--check') can be changed by renaming the binary. If you want to have a tool that repairs tables by default, you should just make a copy of note 'mysqlcheck': mysqlcheck. named 'mysqlrepair', or make a symbolic link to *note 'mysqlcheck': mysqlcheck. named 'mysqlrepair'. If you invoke 'mysqlrepair', it repairs tables.
The names shown in the following table can be used to change *note 'mysqlcheck': mysqlcheck. default behavior.
Command Meaning
'mysqlrepair' The default option is '--repair'
'mysqlanalyze' The default option is '--analyze'
'mysqloptimize' The default option is '--optimize'
note 'mysqlcheck': mysqlcheck. supports the following options, which can be specified on the command line or in the '[mysqlcheck]' and '[client]' groups of an option file. For information about option files used by MySQL programs, see note option-files::.
mysqlcheck Options
Option Name Description IntroducedDeprecated
-all-databases
Check all tables in all databases
-all-in-1
Execute a single statement for each database that names all the tables from that database
-analyze
Analyze the tables
-auto-repair
If a checked table is corrupted, automatically fix it
-bind-address
Use specified network interface to connect to MySQL Server
-character-sets-dir
Directory where character sets are installed
-check
Check the tables for errors
-check-only-changed
Check only tables that have changed since the last check
-check-upgrade
Invoke CHECK TABLE with the FOR UPGRADE option
-compress
Compress all information sent between client and server
-databases
Interpret all arguments as database names
-debug
Write debugging log
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-default-character-set
Specify default character set
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-enable-cleartext-plugin
Enable cleartext 5.7.10 authentication
plugin
-extended
Check and repair tables
-fast
Check only tables that have not been closed properly
-fix-db-names
Convert database Yes names to 5.1
format
-fix-table-names
Convert table Yes names to 5.1
format
-force
Continue even if an SQL error occurs
-get-server-public-key
Request RSA 5.7.23 public key from
server
-help
Display help message and exit
-host
Host on which MySQL server is located
-login-path
Read login path options from .mylogin.cnf
-medium-check
Do a check that is faster than an -extended operation
-no-defaults
Read no option files
-optimize
Optimize the tables
-password
Password to use when connecting to server
-pipe
Connect to server using named pipe (Windows only)
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-print-defaults
Print default options
-protocol
Transport protocol to use
-quick
The fastest method of checking
-repair
Perform a repair that can fix almost anything except unique keys that are not unique
-secure-auth
Do not send Yes passwords to
server in old (pre-4.1) format
-server-public-key-path
Path name to file 5.7.23 containing RSA
public key
-shared-memory-base-name
Shared-memory name for shared-memory connections (Windows only)
-silent
Silent mode
-skip-database
Omit this database from performed operations
-socket
Unix socket file or Windows named pipe to use
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of
connection to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-tables
Overrides the -databases or -B option
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-use-frm
For repair operations on MyISAM tables
-user
MySQL user name to use when connecting to server
-verbose
Verbose mode
-version
Display version information and exit
-write-binlog
Log ANALYZE, OPTIMIZE, REPAIR statements to binary log. -skip-write-binlog adds NO_WRITE_TO_BINLOG to these statements
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--all-databases', '-A'
Command-Line Format
'--all-databases'
Check all tables in all databases. This is the same as using the '--databases' option and naming all the databases on the command line, except that the 'INFORMATION_SCHEMA' and 'performance_schema' databases are not checked. They can be checked by explicitly naming them with the '--databases' option.
'--all-in-1', '-1'
Command-Line Format
'--all-in-1'
Instead of issuing a statement for each table, execute a single statement for each database that names all the tables from that database to be processed.
'--analyze', '-a'
Command-Line Format
'--analyze'
Analyze the tables.
'--auto-repair'
Command-Line Format
'--auto-repair'
If a checked table is corrupted, automatically fix it. Any necessary repairs are done after all tables have been checked.
'--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'
Type
Directory name
The directory where character sets are installed. See *note charset-configuration::.
'--check', '-c'
Command-Line Format
'--check'
Check the tables for errors. This is the default operation.
'--check-only-changed', '-C'
Command-Line Format
'--check-only-changed'
Check only tables that have changed since the last check or that have not been closed properly.
'--check-upgrade', '-g'
Command-Line Format
'--check-upgrade'
Invoke *note 'CHECK TABLE': check-table. with the 'FOR UPGRADE' option to check tables for incompatibilities with the current version of the server. This option automatically enables the '--fix-db-names' and '--fix-table-names' options.
'--compress'
Command-Line Format
'--compress[={OFF|ON}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note connection-compression-control::.
'--databases', '-B'
Command-Line Format
'--databases'
Process all tables in the named databases. Normally, *note 'mysqlcheck': mysqlcheck. treats the first name argument on the command line as a database name and any following names as table names. With this option, it treats all name arguments as database names.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:o'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default is 'd:t:o'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--default-character-set=CHARSET_NAME'
Command-Line Format
'--default-character-set=charset_name'
Type
String
Use CHARSET_NAME as the default character set. See *note charset-configuration::.
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysqlcheck': mysqlcheck. normally reads the '[client]' and '[mysqlcheck]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysqlcheck': mysqlcheck. also reads the '[client_other]' and '[mysqlcheck_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--extended', '-e'
Command-Line Format
'--extended'
If you are using this option to check tables, it ensures that they are 100% consistent but takes a long time.
If you are using this option to repair tables, it runs an extended repair that may not only take a long time to execute, but may produce a lot of garbage rows also!
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--enable-cleartext-plugin'
Command-Line Format
'--enable-cleartext-plugin'
Introduced
5.7.10
Type
Boolean
Default Value
'FALSE'
Enable the 'mysql_clear_password' cleartext authentication plugin. (See *note cleartext-pluggable-authentication::.)
This option was added in MySQL 5.7.10.
'--fast', '-F'
Command-Line Format
'--fast'
Check only tables that have not been closed properly.
'--fix-db-names'
Command-Line Format
'--fix-db-names'
Deprecated
Yes
Convert database names to 5.1 format. Only database names that contain special characters are affected.
This option is deprecated in MySQL 5.7.6; expect it to be removed in a future version of MySQL. If it is necessary to convert MySQL 5.0 database or table names, a workaround is to upgrade a MySQL 5.0 installation to MySQL 5.1 before upgrading to a more recent release.
'--fix-table-names'
Command-Line Format
'--fix-table-names'
Deprecated
Yes
Convert table names to 5.1 format. Only table names that contain special characters are affected. This option also applies to views.
This option is deprecated in MySQL 5.7.6; expect it to be removed in a future version of MySQL. If it is necessary to convert MySQL 5.0 database or table names, a workaround is to upgrade a MySQL 5.0 installation to MySQL 5.1 before upgrading to a more recent release.
'--force', '-f'
Command-Line Format
'--force'
Continue even if an SQL error occurs.
'--get-server-public-key'
Command-Line Format
'--get-server-public-key'
Introduced
5.7.23
Type
Boolean
Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the 'caching_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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host=host_name'
Type
String
Default Value
'localhost'
Connect to the MySQL server on the given host.
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--medium-check', '-m'
Command-Line Format
'--medium-check'
Do a check that is faster than an '--extended' operation. This finds only 99.99% of all errors, which should be good enough in most cases.
'--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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--optimize', '-o'
Command-Line Format
'--optimize'
Optimize the tables.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysqlcheck': mysqlcheck. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysqlcheck': mysqlcheck. should not prompt for one, use the '--skip-password' option.
'--pipe', '-W'
Command-Line Format
'--pipe'
Type
String
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the 'named_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 the 'named_pipe_full_access_group' system variable.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysqlcheck': mysqlcheck. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
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, see *note option-file-options::.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note transport-protocols::.
'--quick', '-q'
Command-Line Format
'--quick'
If you are using this option to check tables, it prevents the check from scanning the rows to check for incorrect links. This is the fastest check method.
If you are using this option to repair tables, it tries to repair only the index tree. This is the fastest repair method.
'--repair', '-r'
Command-Line Format
'--repair'
Perform a repair that can fix almost anything except unique keys that are not unique.
'--secure-auth'
Command-Line Format
'--secure-auth'
Deprecated
Yes
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, see *note account-upgrades::.
'--server-public-key-path=FILE_NAME'
Command-Line Format
'--server-public-key-path=file_name'
Introduced
5.7.23
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
The '--server-public-key-path' option was added in MySQL 5.7.23.
'--shared-memory-base-name=NAME'
Command-Line Format
'--shared-memory-base-name=name'
Platform Specific
Windows
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 'MYSQL'. The shared-memory name is case-sensitive.
This option applies only if the server was started with the 'shared_memory' system variable enabled to support shared-memory connections.
'--silent', '-s'
Command-Line Format
'--silent'
Silent mode. Print only error messages.
'--skip-database=DB_NAME'
Command-Line Format
'--skip-database=db_name'
Do not include the named database (case-sensitive) in the operations performed by *note 'mysqlcheck': mysqlcheck.
'--socket=PATH', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_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. See *note encrypted-connection-options::.
'--tables'
Command-Line Format
'--tables'
Override the '--databases' or '-B' option. All name arguments following the option are regarded as table names.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-ciphers::.
This option was added in MySQL 5.7.10.
'--use-frm'
Command-Line Format
'--use-frm'
For repair operations on 'MyISAM' tables, get the table structure from the '.frm' file so that the table can be repaired even if the '.MYI' header is corrupted.
'--user=USER_NAME', '-u USER_NAME'
Command-Line Format
'--user=user_name,'
Type
String
The user name of the MySQL account to use for connecting to the server.
'--verbose', '-v'
Command-Line Format
'--verbose'
Verbose mode. Print information about the various stages of program operation.
'--version', '-V'
Command-Line Format
'--version'
Display version information and exit.
'--write-binlog'
Command-Line Format
'--write-binlog'
This option is enabled by default, so that note 'ANALYZE TABLE': analyze-table, note 'OPTIMIZE TABLE': optimize-table, and note 'REPAIR TABLE': repair-table. statements generated by note 'mysqlcheck': mysqlcheck. are written to the binary log. Use '--skip-write-binlog' to cause 'NO_WRITE_TO_BINLOG' to be added to the statements so that they are not logged. Use the '--skip-write-binlog' when these statements should not be sent to replicas or run when using the binary logs for recovery from backup.
File: manual.info.tmp, Node: mysqldump, Next: mysqlimport, Prev: mysqlcheck, Up: programs-client
The note 'mysqldump': mysqldump. client utility performs logical backups, producing a set of SQL statements that can be executed to reproduce the original database object definitions and table data. It dumps one or more MySQL databases for backup or transfer to another SQL server. The note 'mysqldump': mysqldump. command can also generate output in CSV, other delimited text, or XML format.
*note mysqldump-performance::
*note mysqldump-syntax::
*note mysqldump-option-summary::
*note mysqldump-connection-options::
*note mysqldump-option-file-options::
*note mysqldump-ddl-options::
*note mysqldump-debug-options::
*note mysqldump-help-options::
*note mysqldump-i18n-options::
*note mysqldump-replication-options::
*note mysqldump-format-options::
*note mysqldump-filter-options::
*note mysqldump-performance-options::
*note mysqldump-transaction-options::
*note mysqldump-option-groups::
*note mysqldump-option-examples::
*note mysqldump-restrictions::
*note 'mysqldump': mysqldump. requires at least the 'SELECT' privilege for dumped tables, 'SHOW VIEW' for dumped views, 'TRIGGER' for dumped triggers, 'LOCK TABLES' if the '--single-transaction' option is not used, and (as of MySQL 5.7.31) 'PROCESS' if the '--no-tablespaces' option is not used. Certain options might require other privileges as noted in the option descriptions.
To reload a dump file, you must have the privileges required to execute the statements that it contains, such as the appropriate 'CREATE' privileges for objects created by those statements.
note 'mysqldump': mysqldump. output can include note 'ALTER DATABASE': alter-database. statements that change the database collation. These may be used when dumping stored programs to preserve their character encodings. To reload a dump file containing such statements, the 'ALTER' privilege for the affected database is required.
Note:
A dump made using PowerShell on Windows with output redirection creates a file that has UTF-16 encoding:
mysqldump [options] > dump.sql
However, UTF-16 is not permitted as a connection character set (see *note charset-connection-impermissible-client-charset::), so the dump file cannot be loaded correctly. To work around this issue, use the '--result-file' option, which creates the output in ASCII format:
mysqldump [options] --result-file=dump.sql
It is not recommended to load a dump file when GTIDs are enabled on the server ('gtid_mode=ON'), if your dump file includes system tables. *note 'mysqldump': mysqldump. issues DML instructions for the system tables which use the non-transactional MyISAM storage engine, and this combination is not permitted when GTIDs are enabled.
Performance and Scalability Considerations
'mysqldump' advantages include the convenience and flexibility of viewing or even editing the output before restoring. You can clone databases for development and DBA work, or produce slight variations of an existing database for testing. It is not intended as a fast or scalable solution for backing up substantial amounts of data. With large data sizes, even if the backup step takes a reasonable time, restoring the data can be very slow because replaying the SQL statements involves disk I/O for insertion, index creation, and so on.
For large-scale backup and restore, a physical backup is more appropriate, to copy the data files in their original format that can be restored quickly:
*note 'mysqldump': mysqldump. can retrieve and dump table contents row by row, or it can retrieve the entire content from a table and buffer it in memory before dumping it. Buffering in memory can be a problem if you are dumping large tables. To dump tables row by row, use the '--quick' option (or '--opt', which enables '--quick'). The '--opt' option (and hence '--quick') is enabled by default, so to enable memory buffering, use '--skip-quick'.
If you are using a recent version of *note 'mysqldump': mysqldump. to generate a dump to be reloaded into a very old MySQL server, use the '--skip-opt' option instead of the '--opt' or '--extended-insert' option.
For additional information about note 'mysqldump': mysqldump, see note using-mysqldump::.
Invocation Syntax
There are in general three ways to use *note 'mysqldump': mysqldump.--in order to dump a set of one or more tables, a set of one or more complete databases, or an entire MySQL server--as shown here:
mysqldump [OPTIONS] DB_NAME [TBL_NAME ...]
mysqldump [OPTIONS] --databases DB_NAME ...
mysqldump [OPTIONS] --all-databases
To dump entire databases, do not name any tables following DB_NAME, or use the '--databases' or '--all-databases' option.
To see a list of the options your version of note 'mysqldump': mysqldump. supports, issue the command note 'mysqldump --help': mysqldump.
Option Syntax - Alphabetical Summary
note 'mysqldump': mysqldump. supports the following options, which can be specified on the command line or in the '[mysqldump]' and '[client]' groups of an option file. For information about option files used by MySQL programs, see note option-files::.
mysqldump Options
Option Name Description IntroducedDeprecated
-add-drop-database
Add DROP DATABASE statement before each CREATE DATABASE statement
-add-drop-table
Add DROP TABLE statement before each CREATE TABLE statement
-add-drop-trigger
Add DROP TRIGGER statement before each CREATE TRIGGER statement
-add-locks
Surround each table dump with LOCK TABLES and UNLOCK TABLES statements
-all-databases
Dump all tables in all databases
-allow-keywords
Allow creation of column names that are keywords
-apply-slave-statements
Include STOP SLAVE prior to CHANGE MASTER statement and START SLAVE at end of output
-bind-address
Use specified network interface to connect to MySQL Server
-character-sets-dir
Directory where character sets are installed
-comments
Add comments to dump file
-compact
Produce more compact output
-compatible
Produce output that is more compatible with other database systems or with older MySQL servers
-complete-insert
Use complete INSERT statements that include column names
-compress
Compress all information sent between client and server
-create-options
Include all MySQL-specific table options in CREATE TABLE statements
-databases
Interpret all name arguments as database names
-debug
Write debugging log
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-default-character-set
Specify default character set
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-delete-master-logs
On a replication source server, delete the binary logs after performing the dump operation
-disable-keys
For each table, surround INSERT statements with statements to disable and enable keys
-dump-date
Include dump date as "Dump completed on" comment if -comments is given
-dump-slave
Include CHANGE MASTER statement that lists binary log coordinates of replica's source
-enable-cleartext-plugin
Enable cleartext 5.7.10 authentication
plugin
-events
Dump events from dumped databases
-extended-insert
Use multiple-row INSERT syntax
-fields-enclosed-by
This option is used with the -tab option and has the same meaning as the corresponding clause for LOAD DATA
-fields-escaped-by
This option is used with the -tab option and has the same meaning as the corresponding clause for LOAD DATA
-fields-optionally-enclosed-by
This option is used with the -tab option and has the same meaning as the corresponding clause for LOAD DATA
-fields-terminated-by
This option is used with the -tab option and has the same meaning as the corresponding clause for LOAD DATA
-flush-logs
Flush MySQL server log files before starting dump
-flush-privileges
Emit a FLUSH PRIVILEGES statement after dumping mysql database
-force
Continue even if an SQL error occurs during a table dump
-get-server-public-key
Request RSA 5.7.23 public key from
server
-help
Display help message and exit
-hex-blob
Dump binary columns using hexadecimal notation
-host
Host on which MySQL server is located
-ignore-error
Ignore specified errors
-ignore-table
Do not dump given table
-include-master-host-port
Include MASTER_HOST/MASTER_PORT options in CHANGE MASTER statement produced with -dump-slave
-insert-ignore
Write INSERT IGNORE rather than INSERT statements
-lines-terminated-by
This option is used with the -tab option and has the same meaning as the corresponding clause for LOAD DATA
-lock-all-tables
Lock all tables across all databases
-lock-tables
Lock all tables before dumping them
-log-error
Append warnings and errors to named file
-login-path
Read login path options from .mylogin.cnf
-master-data
Write the binary log file name and position to the output
-max-allowed-packet
Maximum packet length to send to or receive from server
-net-buffer-length
Buffer size for TCP/IP and socket communication
-no-autocommit
Enclose the INSERT statements for each dumped table within SET autocommit = 0 and COMMIT statements
-no-create-db
Do not write CREATE DATABASE statements
-no-create-info
Do not write CREATE TABLE statements that re-create each dumped table
-no-data
Do not dump table contents
-no-defaults
Read no option files
-no-set-names
Same as -skip-set-charset
-no-tablespaces
Do not write any CREATE LOGFILE GROUP or CREATE TABLESPACE statements in output
-opt
Shorthand for -add-drop-table -add-locks -create-options -disable-keys -extended-insert -lock-tables -quick -set-charset
-order-by-primary
Dump each table's rows sorted by its primary key, or by its first unique index
-password
Password to use when connecting to server
-pipe
Connect to server using named pipe (Windows only)
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-print-defaults
Print default options
-protocol
Transport protocol to use
-quick
Retrieve rows for a table from the server a row at a time
-quote-names
Quote identifiers within backtick characters
-replace
Write REPLACE statements rather than INSERT statements
-result-file
Direct output to a given file
-routines
Dump stored routines (procedures and functions) from dumped databases
-secure-auth
Do not send Yes passwords to
server in old (pre-4.1) format
-server-public-key-path
Path name to file 5.7.23 containing RSA
public key
-set-charset
Add SET NAMES default_character_set to output
-set-gtid-purged
Whether to add SET @@GLOBAL.GTID_PURGED to output
-shared-memory-base-name
Shared-memory name for shared-memory connections (Windows only)
-single-transaction
Issue a BEGIN SQL statement before dumping data from server
-skip-add-drop-table
Do not add a DROP TABLE statement before each CREATE TABLE statement
-skip-add-locks
Do not add locks
-skip-comments
Do not add comments to dump file
-skip-compact
Do not produce more compact output
-skip-disable-keys
Do not disable keys
-skip-extended-insert
Turn off extended-insert
-skip-mysql-schema
Do not drop the 5.7.36 mysql schema
-skip-opt
Turn off options set by -opt
-skip-quick
Do not retrieve rows for a table from the server a row at a time
-skip-quote-names
Do not quote identifiers
-skip-set-charset
Do not write SET NAMES statement
-skip-triggers
Do not dump triggers
-skip-tz-utc
Turn off tz-utc
-socket
Unix socket file or Windows named pipe to use
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of
connection to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-tab
Produce tab-separated data files
-tables
Override -databases or -B option
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-triggers
Dump triggers for each dumped table
-tz-utc
Add SET TIME_ZONE='+00:00' to dump file
-user
MySQL user name to use when connecting to server
-verbose
Verbose mode
-version
Display version information and exit
-where
Dump only rows selected by given WHERE condition
-xml
Produce XML output
Connection Options
The *note 'mysqldump': mysqldump. command logs into a MySQL server to extract information. The following options specify how to connect to the MySQL server, either on the same machine or a remote system.
'--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.
'--compress', '-C'
Command-Line Format
'--compress[={OFF|ON}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note connection-compression-control::.
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--enable-cleartext-plugin'
Command-Line Format
'--enable-cleartext-plugin'
Introduced
5.7.10
Type
Boolean
Default Value
'FALSE'
Enable the 'mysql_clear_password' cleartext authentication plugin. (See *note cleartext-pluggable-authentication::.)
This option was added in MySQL 5.7.10.
'--get-server-public-key'
Command-Line Format
'--get-server-public-key'
Introduced
5.7.23
Type
Boolean
Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the 'caching_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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host'
Dump data from the MySQL server on the given host. The default host is 'localhost'.
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysqldump': mysqldump. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysqldump': mysqldump. should not prompt for one, use the '--skip-password' option.
'--pipe', '-W'
Command-Line Format
'--pipe'
Type
String
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the 'named_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 the 'named_pipe_full_access_group' system variable.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysqldump': mysqldump. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
For TCP/IP connections, the port number to use.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note transport-protocols::.
'--secure-auth'
Command-Line Format
'--secure-auth'
Deprecated
Yes
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, see *note account-upgrades::.
'--server-public-key-path=FILE_NAME'
Command-Line Format
'--server-public-key-path=file_name'
Introduced
5.7.23
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
The '--server-public-key-path' option was added in MySQL 5.7.23.
'--skip-mysql-schema'
Command-Line Format
'--skip-mysql-schema'
Introduced
5.7.36
Type
Boolean
Do not drop the 'mysql' schema when the dump file is restored. By default, the schema is dropped.
This option was added in MySQL 5.7.36.
'--socket=PATH', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_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. See *note encrypted-connection-options::.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-ciphers::.
This option was added in MySQL 5.7.10.
'--user=USER_NAME', '-u USER_NAME'
Command-Line Format
'--user=user_name'
Type
String
The user name of the MySQL account to use for connecting to the server.
Option-File Options
These options are used to control which option files to read.
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysqldump': mysqldump. normally reads the '[client]' and '[mysqldump]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysqldump': mysqldump. also reads the '[client_other]' and '[mysqldump_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--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, see *note option-file-options::.
DDL Options
Usage scenarios for *note 'mysqldump': mysqldump. include setting up an entire new MySQL instance (including database tables), and replacing data inside an existing instance with existing databases and tables. The following options let you specify which things to tear down and set up when restoring a dump, by encoding various DDL statements within the dump file.
'--add-drop-database'
Command-Line Format
'--add-drop-database'
Write a note 'DROP DATABASE': drop-database. statement before each note 'CREATE DATABASE': create-database. statement. This option is typically used in conjunction with the '--all-databases' or '--databases' option because no *note 'CREATE DATABASE': create-database. statements are written unless one of those options is specified.
'--add-drop-table'
Command-Line Format
'--add-drop-table'
Write a note 'DROP TABLE': drop-table. statement before each note 'CREATE TABLE': create-table. statement.
'--add-drop-trigger'
Command-Line Format
'--add-drop-trigger'
Write a note 'DROP TRIGGER': drop-trigger. statement before each note 'CREATE TRIGGER': create-trigger. statement.
'--all-tablespaces', '-Y'
Command-Line Format
'--all-tablespaces'
Adds to a table dump all SQL statements needed to create any tablespaces used by an note 'NDB': mysql-cluster. table. This information is not otherwise included in the output from note 'mysqldump': mysqldump. This option is currently relevant only to NDB Cluster tables, which are not supported in MySQL 5.7.
'--no-create-db', '-n'
Command-Line Format
'--no-create-db'
Suppress the *note 'CREATE DATABASE': create-database. statements that are otherwise included in the output if the '--databases' or '--all-databases' option is given.
'--no-create-info', '-t'
Command-Line Format
'--no-create-info'
Do not write *note 'CREATE TABLE': create-table. statements that create each dumped table.
Note:
This option does not exclude statements creating log file groups or tablespaces from *note 'mysqldump': mysqldump. output; however, you can use the '--no-tablespaces' option for this purpose.
'--no-tablespaces', '-y'
Command-Line Format
'--no-tablespaces'
This option suppresses all note 'CREATE LOGFILE GROUP': create-logfile-group. and note 'CREATE TABLESPACE': create-tablespace. statements in the output of *note 'mysqldump': mysqldump.
'--replace'
Command-Line Format
'--replace'
Write note 'REPLACE': replace. statements rather than note 'INSERT': insert. statements.
Debug Options
The following options print debugging information, encode debugging information in the dump file, or let the dump operation proceed regardless of potential problems.
'--allow-keywords'
Command-Line Format
'--allow-keywords'
Permit creation of column names that are keywords. This works by prefixing each column name with the table name.
'--comments', '-i'
Command-Line Format
'--comments'
Write additional information in the dump file such as program version, server version, and host. This option is enabled by default. To suppress this additional information, use '--skip-comments'.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:o,/tmp/mysqldump.trace'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default value is 'd:t:o,/tmp/mysqldump.trace'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--dump-date'
Command-Line Format
'--dump-date'
Type
Boolean
Default Value
'TRUE'
If the '--comments' option is given, *note 'mysqldump': mysqldump. produces a comment at the end of the dump of the following form:
-- Dump completed on DATE
However, the date causes dump files taken at different times to appear to be different, even if the data are otherwise identical. '--dump-date' and '--skip-dump-date' control whether the date is added to the comment. The default is '--dump-date' (include the date in the comment). '--skip-dump-date' suppresses date printing.
'--force', '-f'
Command-Line Format
'--force'
Ignore all errors; continue even if an SQL error occurs during a table dump.
One use for this option is to cause note 'mysqldump': mysqldump. to continue executing even when it encounters a view that has become invalid because the definition refers to a table that has been dropped. Without '--force', note 'mysqldump': mysqldump. exits with an error message. With '--force', *note 'mysqldump': mysqldump. prints the error message, but it also writes an SQL comment containing the view definition to the dump output and continues executing.
If the '--ignore-error' option is also given to ignore specific errors, '--force' takes precedence.
'--log-error=FILE_NAME'
Command-Line Format
'--log-error=file_name'
Type
File name
Log warnings and errors by appending them to the named file. The default is to do no logging.
'--skip-comments'
Command-Line Format
'--skip-comments'
See the description for the '--comments' option.
'--verbose', '-v'
Command-Line Format
'--verbose'
Verbose mode. Print more information about what the program does.
Help Options
The following options display information about the *note 'mysqldump': mysqldump. command itself.
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--version', '-V'
Command-Line Format
'--version'
Display version information and exit.
Internationalization Options
The following options change how the *note 'mysqldump': mysqldump. command represents character data with national language settings.
'--character-sets-dir=DIR_NAME'
Command-Line Format
'--character-sets-dir=dir_name'
Type
Directory name
The directory where character sets are installed. See *note charset-configuration::.
'--default-character-set=CHARSET_NAME'
Command-Line Format
'--default-character-set=charset_name'
Type
String
Default Value
'utf8'
Use CHARSET_NAME as the default character set. See note charset-configuration::. If no character set is specified, note 'mysqldump': mysqldump. uses 'utf8'.
'--no-set-names', '-N'
Command-Line Format
'--no-set-names'
Deprecated
Yes
Turns off the '--set-charset' setting, the same as specifying '--skip-set-charset'.
'--set-charset'
Command-Line Format
'--set-charset'
Disabled by
'skip-set-charset'
Write note 'SET NAMES DEFAULT_CHARACTER_SET': set-names. to the output. This option is enabled by default. To suppress the note 'SET NAMES': set-names. statement, use '--skip-set-charset'.
Replication Options
The *note 'mysqldump': mysqldump. command is frequently used to create an empty instance, or an instance including data, on a replica server in a replication configuration. The following options apply to dumping and restoring data on replication source and replica servers.
'--apply-slave-statements'
Command-Line Format
'--apply-slave-statements'
Type
Boolean
Default Value
'FALSE'
For a replica dump produced with the '--dump-slave' option, add a note 'STOP SLAVE': stop-slave. statement before the note 'CHANGE MASTER TO': change-master-to. statement and a *note 'START SLAVE': start-slave. statement at the end of the output.
'--delete-master-logs'
Command-Line Format
'--delete-master-logs'
On a source replication server, delete the binary logs by sending a *note 'PURGE BINARY LOGS': purge-binary-logs. statement to the server after performing the dump operation. This option requires the 'RELOAD' privilege as well as privileges sufficient to execute that statement. This option automatically enables '--master-data'.
'--dump-slave[=VALUE]'
Command-Line Format
'--dump-slave[=value]'
Type
Numeric
Default Value
'1'
Valid Values
'1' '2'
This option is similar to '--master-data' except that it is used to dump a replication replica server to produce a dump file that can be used to set up another server as a replica that has the same source as the dumped server. It causes the dump output to include a note 'CHANGE MASTER TO': change-master-to. statement that indicates the binary log coordinates (file name and position) of the dumped replica's source. The note 'CHANGE MASTER TO': change-master-to. statement reads the values of 'Relay_Master_Log_File' and 'Exec_Master_Log_Pos' from the *note 'SHOW SLAVE STATUS': show-slave-status. output and uses them for 'MASTER_LOG_FILE' and 'MASTER_LOG_POS' respectively. These are the source server coordinates from which the replica should start replicating.
Note:
Inconsistencies in the sequence of transactions from the relay log which have been executed can cause the wrong position to be used. See *note replication-features-transaction-inconsistencies:: for more information.
'--dump-slave' causes the coordinates from the source to be used rather than those of the dumped server, as is done by the '--master-data' option. In addition, specifiying this option causes the '--master-data' option to be overridden, if used, and effectively ignored.
Warning:
This option should not be used if the server where the dump is going to be applied uses 'gtid_mode=ON' and 'MASTER_AUTOPOSITION=1'.
The option value is handled the same way as for '--master-data' (setting no value or 1 causes a 'CHANGE MASTER TO' statement to be written to the dump, setting 2 causes the statement to be written but encased in SQL comments) and has the same effect as '--master-data' in terms of enabling or disabling other options and in how locking is handled.
This option causes *note 'mysqldump': mysqldump. to stop the replica SQL thread before the dump and restart it again after.
'--dump-slave' sends a *note 'SHOW SLAVE STATUS': show-slave-status. statement to the server to obtain information, so it requires privileges sufficient to execute that statement.
In conjunction with '--dump-slave', the '--apply-slave-statements' and '--include-master-host-port' options can also be used.
'--include-master-host-port'
Command-Line Format
'--include-master-host-port'
Type
Boolean
Default Value
'FALSE'
For the *note 'CHANGE MASTER TO': change-master-to. statement in a replica dump produced with the '--dump-slave' option, add 'MASTER_HOST' and 'MASTER_PORT' options for the host name and TCP/IP port number of the replica's source.
'--master-data[=VALUE]'
Command-Line Format
'--master-data[=value]'
Type
Numeric
Default Value
'1'
Valid Values
'1' '2'
Use this option to dump a source replication server to produce a dump file that can be used to set up another server as a replica of the source. It causes the dump output to include a *note 'CHANGE MASTER TO': change-master-to. statement that indicates the binary log coordinates (file name and position) of the dumped server. These are the source server coordinates from which the replica should start replicating after you load the dump file into the replica.
If the option value is 2, the *note 'CHANGE MASTER TO': change-master-to. statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded. If the option value is 1, the statement is not written as a comment and takes effect when the dump file is reloaded. If no option value is specified, the default value is 1.
'--master-data' sends a *note 'SHOW MASTER STATUS': show-master-status. statement to the server to obtain information, so it requires privileges sufficient to execute that statement. This option also requires the 'RELOAD' privilege and the binary log must be enabled.
The '--master-data' option automatically turns off '--lock-tables'. It also turns on '--lock-all-tables', unless '--single-transaction' also is specified, in which case, a global read lock is acquired only for a short time at the beginning of the dump (see the description for '--single-transaction'). In all cases, any action on logs happens at the exact moment of the dump.
It is also possible to set up a replica by dumping an existing replica of the source, using the '--dump-slave' option, which overrides '--master-data' and causes it to be ignored if both options are used.
'--set-gtid-purged=VALUE'
Command-Line Format
'--set-gtid-purged=value'
Type
Enumeration
Default Value
'AUTO'
Valid Values
'OFF' 'ON' 'AUTO'
This option enables control over global transaction ID (GTID) information written to the dump file, by indicating whether to add a *note 'SET @@GLOBAL.gtid_purged': set-variable. statement to the output. This option may also cause a statement to be written to the output that disables binary logging while the dump file is being reloaded.
The following table shows the permitted option values. The default value is 'AUTO'.
Value Meaning
'OFF' Add no 'SET' statement to the output.
'ON' Add a 'SET' statement to the output. An error occurs if GTIDs are not enabled on the server.
'AUTO' Add a 'SET' statement to the output if GTIDs are enabled on the server.
A partial dump from a server that is using GTID-based replication requires the '--set-gtid-purged={ON|OFF}' option to be specified. Use 'ON' if the intention is to deploy a new replication replica using only some of the data from the dumped server. Use 'OFF' if the intention is to repair a table by copying it within a topology. Use 'OFF' if the intention is to copy a table between replication topologies that are disjoint and for them to remain so.
The '--set-gtid-purged' option has the following effect on binary logging when the dump file is reloaded:
* '--set-gtid-purged=OFF': 'SET @@SESSION.SQL_LOG_BIN=0;' is not
added to the output.
* '--set-gtid-purged=ON': 'SET @@SESSION.SQL_LOG_BIN=0;' is
added to the output.
* '--set-gtid-purged=AUTO': 'SET @@SESSION.SQL_LOG_BIN=0;' is
added to the output if GTIDs are enabled on the server you are
backing up (that is, if 'AUTO' evaluates to 'ON').
Using this option with the '--single-transaction' option can lead to inconsistencies in the output. If '--set-gtid-purged=ON' is required, it can be used with '--lock-all-tables', but this can prevent parallel queries while *note 'mysqldump': mysqldump. is being run.
It is not recommended to load a dump file when GTIDs are enabled on the server ('gtid_mode=ON'), if your dump file includes system tables. *note 'mysqldump': mysqldump. issues DML instructions for the system tables which use the non-transactional MyISAM storage engine, and this combination is not permitted when GTIDs are enabled. Also be aware that loading a dump file from a server with GTIDs enabled, into another server with GTIDs enabled, causes different transaction identifiers to be generated.
Format Options
The following options specify how to represent the entire dump file or certain kinds of data in the dump file. They also control whether certain optional information is written to the dump file.
'--compact'
Command-Line Format
'--compact'
Produce more compact output. This option enables the '--skip-add-drop-table', '--skip-add-locks', '--skip-comments', '--skip-disable-keys', and '--skip-set-charset' options.
'--compatible=NAME'
Command-Line Format
'--compatible=name[,name,...]'
Type
String
Default Value
''''
Valid Values
'ansi' 'mysql323' 'mysql40' 'postgresql' 'oracle' 'mssql' 'db2' 'maxdb' 'no_key_options' 'no_table_options' 'no_key_options'
Produce output that is more compatible with other database systems or with older MySQL servers. The value of NAME can be 'ansi', 'mysql323', 'mysql40', 'postgresql', 'oracle', 'mssql', 'db2', 'maxdb', 'no_key_options', 'no_table_options', or 'no_field_options'. To use several values, separate them by commas. These values have the same meaning as the corresponding options for setting the server SQL mode. See *note sql-mode::.
This option does not guarantee compatibility with other servers. It only enables those SQL mode values that are currently available for making dump output more compatible. For example, '--compatible=oracle' does not map data types to Oracle types or use Oracle comment syntax.
'--complete-insert', '-c'
Command-Line Format
'--complete-insert'
Use complete *note 'INSERT': insert. statements that include column names.
'--create-options'
Command-Line Format
'--create-options'
Include all MySQL-specific table options in the *note 'CREATE TABLE': create-table. statements.
'--fields-terminated-by=...', '--fields-enclosed-by=...', '--fields-optionally-enclosed-by=...', '--fields-escaped-by=...'
Command-Line Format
'--fields-terminated-by=string'
Type
String
Command-Line Format
'--fields-enclosed-by=string'
Type
String
Command-Line Format
'--fields-optionally-enclosed-by=string'
Type
String
Command-Line Format
'--fields-escaped-by'
Type
String
These options are used with the '--tab' option and have the same meaning as the corresponding 'FIELDS' clauses for note 'LOAD DATA': load-data. See note load-data::.
'--hex-blob'
Command-Line Format
'--hex-blob'
Dump binary columns using hexadecimal notation (for example, ''abc'' becomes '0x616263'). The affected data types are note 'BINARY': binary-varbinary, note 'VARBINARY': binary-varbinary, note 'BLOB': blob. types, note 'BIT': bit-type, all spatial data types, and other non-binary data types when used with the *note 'binary' character set: charset-binary-set.
The '--hex-blob' option is ignored when the '--tab' is used.
'--lines-terminated-by=...'
Command-Line Format
'--lines-terminated-by=string'
Type
String
This option is used with the '--tab' option and has the same meaning as the corresponding 'LINES' clause for note 'LOAD DATA': load-data. See note load-data::.
'--quote-names', '-Q'
Command-Line Format
'--quote-names'
Disabled by
'skip-quote-names'
Quote identifiers (such as database, table, and column names) within '`' characters. If the 'ANSI_QUOTES' SQL mode is enabled, identifiers are quoted within '"' characters. This option is enabled by default. It can be disabled with '--skip-quote-names', but this option should be given after any option such as '--compatible' that may enable '--quote-names'.
'--result-file=FILE_NAME', '-r FILE_NAME'
Command-Line Format
'--result-file=file_name'
Type
File name
Direct output to the named file. The result file is created and its previous contents overwritten, even if an error occurs while generating the dump.
This option should be used on Windows to prevent newline '' characters from being converted to '' carriage return/newline sequences.
'--tab=DIR_NAME', '-T DIR_NAME'
Command-Line Format
'--tab=dir_name'
Type
Directory name
Produce tab-separated text-format data files. For each dumped table, note 'mysqldump': mysqldump. creates a 'TBL_NAME.sql' file that contains the note 'CREATE TABLE': create-table. statement that creates the table, and the server writes a 'TBL_NAME.txt' file that contains its data. The option value is the directory in which to write the files.
Note:
This option should be used only when note 'mysqldump': mysqldump. is run on the same machine as the note 'mysqld': mysqld. server. Because the server creates '.txt' files in the directory that you specify, the directory must be writable by the server and the MySQL account that you use must have the 'FILE' privilege. Because note 'mysqldump': mysqldump. creates '*.sql' in the same directory, it must be writable by your system login account.
By default, the '.txt' data files are formatted using tab characters between column values and a newline at the end of each line. The format can be specified explicitly using the '--fields-XXX' and '--lines-terminated-by' options.
Column values are converted to the character set specified by the '--default-character-set' option.
'--tz-utc'
Command-Line Format
'--tz-utc'
Disabled by
'skip-tz-utc'
This option enables note 'TIMESTAMP': datetime. columns to be dumped and reloaded between servers in different time zones. note 'mysqldump': mysqldump. sets its connection time zone to UTC and adds 'SET TIME_ZONE='+00:00'' to the dump file. Without this option, *note 'TIMESTAMP': datetime. columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change if the servers are in different time zones. '--tz-utc' also protects against changes due to daylight saving time. '--tz-utc' is enabled by default. To disable it, use '--skip-tz-utc'.
'--xml', '-X'
Command-Line Format
'--xml'
Write dump output as well-formed XML.
'NULL', ''NULL'', and Empty Values: For a column named COLUMN_NAME, the 'NULL' value, an empty string, and the string value ''NULL'' are distinguished from one another in the output generated by this option as follows.
Value: XML Representation:
'NULL' (unknown value)
'
'''' (empty string)
'
''NULL'' (string value)
'
The output from the note 'mysql': mysql. client when run using the '--xml' option also follows the preceding rules. (See note mysql-command-options::.)
XML output from *note 'mysqldump': mysqldump. includes the XML namespace, as shown here:
$> mysqldump --xml -u root world City
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="world">
<table_structure name="City">
<field Field="ID" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
<field Field="Name" Type="char(35)" Null="NO" Key="" Default="" Extra="" />
<field Field="CountryCode" Type="char(3)" Null="NO" Key="" Default="" Extra="" />
<field Field="District" Type="char(20)" Null="NO" Key="" Default="" Extra="" />
<field Field="Population" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
<key Table="City" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID"
Collation="A" Cardinality="4079" Null="" Index_type="BTREE" Comment="" />
<options Name="City" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="4079"
Avg_row_length="67" Data_length="273293" Max_data_length="18858823439613951"
Index_length="43008" Data_free="0" Auto_increment="4080"
Create_time="2007-03-31 01:47:01" Update_time="2007-03-31 01:47:02"
Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_data name="City">
<row>
<field name="ID">1</field>
<field name="Name">Kabul</field>
<field name="CountryCode">AFG</field>
<field name="District">Kabol</field>
<field name="Population">1780000</field>
</row>
...
<row>
<field name="ID">4079</field>
<field name="Name">Rafah</field>
<field name="CountryCode">PSE</field>
<field name="District">Rafah</field>
<field name="Population">92020</field>
</row>
</table_data>
</database>
</mysqldump>
Filtering Options
The following options control which kinds of schema objects are written to the dump file: by category, such as triggers or events; by name, for example, choosing which databases and tables to dump; or even filtering rows from the table data using a 'WHERE' clause.
'--all-databases', '-A'
Command-Line Format
'--all-databases'
Dump all tables in all databases. This is the same as using the '--databases' option and naming all the databases on the command line.
'--databases', '-B'
Command-Line Format
'--databases'
Dump several databases. Normally, note 'mysqldump': mysqldump. treats the first name argument on the command line as a database name and following names as table names. With this option, it treats all name arguments as database names. note 'CREATE DATABASE': create-database. and *note 'USE': use. statements are included in the output before each new database.
This option may be used to dump the 'INFORMATION_SCHEMA' and 'performance_schema' databases, which normally are not dumped even with the '--all-databases' option. (Also use the '--skip-lock-tables' option.)
'--events', '-E'
Command-Line Format
'--events'
Include Event Scheduler events for the dumped databases in the output. This option requires the 'EVENT' privileges for those databases.
The output generated by using '--events' contains *note 'CREATE EVENT': create-event. statements to create the events. However, these statements do not include attributes such as the event creation and modification timestamps, so when the events are reloaded, they are created with timestamps equal to the reload time.
If you require events to be created with their original timestamp attributes, do not use '--events'. Instead, dump and reload the contents of the 'mysql.event' table directly, using a MySQL account that has appropriate privileges for the 'mysql' database.
'--ignore-error=ERROR[,ERROR]...'
Command-Line Format
'--ignore-error=error[,error]...'
Type
String
Ignore the specified errors. The option value is a list of comma-separated error numbers specifying the errors to ignore during *note 'mysqldump': mysqldump. execution. If the '--force' option is also given to ignore all errors, '--force' takes precedence.
'--ignore-table=DB_NAME.TBL_NAME'
Command-Line Format
'--ignore-table=db_name.tbl_name'
Type
String
Do not dump the given table, which must be specified using both the database and table names. To ignore multiple tables, use this option multiple times. This option also can be used to ignore views.
'--no-data', '-d'
Command-Line Format
'--no-data'
Do not write any table row information (that is, do not dump table contents). This is useful if you want to dump only the *note 'CREATE TABLE': create-table. statement for the table (for example, to create an empty copy of the table by loading the dump file).
'--routines', '-R'
Command-Line Format
'--routines'
Include stored routines (procedures and functions) for the dumped databases in the output. This option requires the 'SELECT' privilege for the 'mysql.proc' table.
The output generated by using '--routines' contains note 'CREATE PROCEDURE': create-procedure. and note 'CREATE FUNCTION': create-function. statements to create the routines. However, these statements do not include attributes such as the routine creation and modification timestamps, so when the routines are reloaded, they are created with timestamps equal to the reload time.
If you require routines to be created with their original timestamp attributes, do not use '--routines'. Instead, dump and reload the contents of the 'mysql.proc' table directly, using a MySQL account that has appropriate privileges for the 'mysql' database.
'--tables'
Command-Line Format
'--tables'
Override the '--databases' or '-B' option. *note 'mysqldump': mysqldump. regards all name arguments following the option as table names.
'--triggers'
Command-Line Format
'--triggers'
Disabled by
'skip-triggers'
Include triggers for each dumped table in the output. This option is enabled by default; disable it with '--skip-triggers'.
To be able to dump a table's triggers, you must have the 'TRIGGER' privilege for the table.
Multiple triggers are permitted. note 'mysqldump': mysqldump. dumps triggers in activation order so that when the dump file is reloaded, triggers are created in the same activation order. However, if a note 'mysqldump': mysqldump. dump file contains multiple triggers for a table that have the same trigger event and action time, an error occurs for attempts to load the dump file into an older server that does not support multiple triggers. (For a workaround, see *note downgrading-to-previous-series::; you can convert triggers to be compatible with older servers.)
'--where='WHERE_CONDITION'', '-w 'WHERE_CONDITION''
Command-Line Format
'--where='where_condition''
Dump only rows selected by the given 'WHERE' condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter.
Examples:
--where="user='jimf'"
-w"userid>1"
-w"userid<1"
Performance Options
The following options are the most relevant for the performance particularly of the restore operations. For large data sets, restore operation (processing the 'INSERT' statements in the dump file) is the most time-consuming part. When it is urgent to restore data quickly, plan and test the performance of this stage in advance. For restore times measured in hours, you might prefer an alternative backup and restore solution, such as *note MySQL Enterprise Backup: mysql-enterprise-backup. for 'InnoDB'-only and mixed-use databases.
Performance is also affected by the transactional options, primarily for the dump operation.
'--disable-keys', '-K'
Command-Line Format
'--disable-keys'
For each table, surround the note 'INSERT': insert. statements with '/!40000 ALTER TABLE TBL_NAME DISABLE KEYS /;' and '/!40000 ALTER TABLE TBL_NAME ENABLE KEYS */;' statements. This makes loading the dump file faster because the indexes are created after all rows are inserted. This option is effective only for nonunique indexes of 'MyISAM' tables.
'--extended-insert', '-e'
Command-Line Format
'--extended-insert'
Disabled by
'skip-extended-insert'
Write *note 'INSERT': insert. statements using multiple-row syntax that includes several 'VALUES' lists. This results in a smaller dump file and speeds up inserts when the file is reloaded.
'--insert-ignore'
Command-Line Format
'--insert-ignore'
Write note 'INSERT IGNORE': insert. statements rather than note 'INSERT': insert. statements.
'--max-allowed-packet=VALUE'
Command-Line Format
'--max-allowed-packet=value'
Type
Numeric
Default Value
'25165824'
The maximum size of the buffer for client/server communication. The default is 24MB, the maximum is 1GB.
Note:
The value of this option is specific to note 'mysqldump': mysqldump. and should not be confused with the MySQL server's 'max_allowed_packet' system variable; the server value cannot be exceeded by a single packet from note 'mysqldump': mysqldump, regardless of any setting for the *note 'mysqldump': mysqldump. option, even if the latter is larger.
'--net-buffer-length=VALUE'
Command-Line Format
'--net-buffer-length=value'
Type
Numeric
Default Value
'16384'
The initial size of the buffer for client/server communication. When creating multiple-row note 'INSERT': insert. statements (as with the '--extended-insert' or '--opt' option), note 'mysqldump': mysqldump. creates rows up to '--net-buffer-length' bytes long. If you increase this variable, ensure that the MySQL server 'net_buffer_length' system variable has a value at least this large.
'--opt'
Command-Line Format
'--opt'
Disabled by
'skip-opt'
This option, enabled by default, is shorthand for the combination of '--add-drop-table' '--add-locks' '--create-options' '--disable-keys' '--extended-insert' '--lock-tables' '--quick' '--set-charset'. It gives a fast dump operation and produces a dump file that can be reloaded into a MySQL server quickly.
Because the '--opt' option is enabled by default, you only specify its converse, the '--skip-opt' to turn off several default settings. See the discussion of 'mysqldump' option groups for information about selectively enabling or disabling a subset of the options affected by '--opt'.
'--quick', '-q'
Command-Line Format
'--quick'
Disabled by
'skip-quick'
This option is useful for dumping large tables. It forces *note 'mysqldump': mysqldump. to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out.
'--skip-opt'
Command-Line Format
'--skip-opt'
See the description for the '--opt' option.
Transactional Options
The following options trade off the performance of the dump operation, against the reliability and consistency of the exported data.
'--add-locks'
Command-Line Format
'--add-locks'
Surround each table dump with note 'LOCK TABLES': lock-tables. and note 'UNLOCK TABLES': lock-tables. statements. This results in faster inserts when the dump file is reloaded. See *note insert-optimization::.
'--flush-logs', '-F'
Command-Line Format
'--flush-logs'
Flush the MySQL server log files before starting the dump. This option requires the 'RELOAD' privilege. If you use this option in combination with the '--all-databases' option, the logs are flushed for each database dumped. The exception is when using '--lock-all-tables', '--master-data', or '--single-transaction': In this case, the logs are flushed only once, corresponding to the moment that all tables are locked by 'FLUSH TABLES WITH READ LOCK'. If you want your dump and the log flush to happen at exactly the same moment, you should use '--flush-logs' together with '--lock-all-tables', '--master-data', or '--single-transaction'.
'--flush-privileges'
Command-Line Format
'--flush-privileges'
Add a 'FLUSH PRIVILEGES' statement to the dump output after dumping the 'mysql' database. This option should be used any time the dump contains the 'mysql' database and any other database that depends on the data in the 'mysql' database for proper restoration.
Because the dump file contains a 'FLUSH PRIVILEGES' statement, reloading the file requires privileges sufficient to execute that statement.
Note:
For upgrades to MySQL 5.7 or higher from older versions, do not use '--flush-privileges'. For upgrade instructions in this case, see *note upgrading-from-previous-series::.
'--lock-all-tables', '-x'
Command-Line Format
'--lock-all-tables'
Lock all tables across all databases. This is achieved by acquiring a global read lock for the duration of the whole dump. This option automatically turns off '--single-transaction' and '--lock-tables'.
'--lock-tables', '-l'
Command-Line Format
'--lock-tables'
For each dumped database, lock all tables to be dumped before dumping them. The tables are locked with 'READ LOCAL' to permit concurrent inserts in the case of 'MyISAM' tables. For transactional tables such as 'InnoDB', '--single-transaction' is a much better option than '--lock-tables' because it does not need to lock the tables at all.
Because '--lock-tables' locks tables for each database separately, this option does not guarantee that the tables in the dump file are logically consistent between databases. Tables in different databases may be dumped in completely different states.
Some options, such as '--opt', automatically enable '--lock-tables'. If you want to override this, use '--skip-lock-tables' at the end of the option list.
'--no-autocommit'
Command-Line Format
'--no-autocommit'
Enclose the note 'INSERT': insert. statements for each dumped table within 'SET autocommit = 0' and note 'COMMIT': commit. statements.
'--order-by-primary'
Command-Line Format
'--order-by-primary'
Dump each table's rows sorted by its primary key, or by its first unique index, if such an index exists. This is useful when dumping a 'MyISAM' table to be loaded into an 'InnoDB' table, but makes the dump operation take considerably longer.
'--shared-memory-base-name=NAME'
Command-Line Format
'--shared-memory-base-name=name'
Platform Specific
Windows
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 'MYSQL'. The shared-memory name is case-sensitive.
This option applies only if the server was started with the 'shared_memory' system variable enabled to support shared-memory connections.
'--single-transaction'
Command-Line Format
'--single-transaction'
This option sets the transaction isolation mode to 'REPEATABLE READ' and sends a note 'START TRANSACTION': commit. SQL statement to the server before dumping data. It is useful only with transactional tables such as 'InnoDB', because then it dumps the consistent state of the database at the time when note 'START TRANSACTION': commit. was issued without blocking any applications.
The RELOAD or FLUSH_TABLES privilege is required with '--single-transaction' if both gtid_mode=ON and -set-gtid=purged=ON|AUTO. This requirement was added in MySQL 8.0.32.
When using this option, you should keep in mind that only 'InnoDB' tables are dumped in a consistent state. For example, any 'MyISAM' or 'MEMORY' tables dumped while using this option may still change state.
While a '--single-transaction' dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates), no other connection should use the following statements: note 'ALTER TABLE': alter-table, note 'CREATE TABLE': create-table, note 'DROP TABLE': drop-table, note 'RENAME TABLE': rename-table, note 'TRUNCATE TABLE': truncate-table. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause the note 'SELECT': select. that is performed by *note 'mysqldump': mysqldump. to retrieve the table contents to obtain incorrect contents or fail.
The '--single-transaction' option and the '--lock-tables' option are mutually exclusive because *note 'LOCK TABLES': lock-tables. causes any pending transactions to be committed implicitly.
Using '--single-transaction' together with the '--set-gtid-purged' option is not recommended; doing so can lead to inconsistencies in the output of *note 'mysqldump': mysqldump.
To dump large tables, combine the '--single-transaction' option with the '--quick' option.
Option Groups
The '--opt' option turns on several settings that work together to perform a fast dump operation. All of these settings are on by default, because '--opt' is on by default. Thus you rarely if ever specify '--opt'. Instead, you can turn these settings off as a group by specifying '--skip-opt', then optionally re-enable certain settings by specifying the associated options later on the command line.
The '--compact' option turns off several settings that control whether optional statements and comments appear in the output. Again, you can follow this option with other options that re-enable certain settings, or turn all the settings on by using the '--skip-compact' form.
When you selectively enable or disable the effect of a group option, order is important because options are processed first to last. For example, '--disable-keys' '--lock-tables' '--skip-opt' would not have the intended effect; it is the same as '--skip-opt' by itself.
Examples
To make a backup of an entire database:
mysqldump DB_NAME > BACKUP-FILE.SQL
To load the dump file back into the server:
mysql DB_NAME < BACKUP-FILE.SQL
Another way to reload the dump file:
mysql -e "source /PATH-TO-BACKUP/BACKUP-FILE.SQL" DB_NAME
*note 'mysqldump': mysqldump. is also very useful for populating databases by copying data from one MySQL server to another:
mysqldump --opt DB_NAME | mysql --host=REMOTE_HOST -C DB_NAME
You can dump several databases with one command:
mysqldump --databases DB_NAME1 [DB_NAME2 ...] > my_databases.sql
To dump all databases, use the '--all-databases' option:
mysqldump --all-databases > all_databases.sql
For 'InnoDB' tables, *note 'mysqldump': mysqldump. provides a way of making an online backup:
mysqldump --all-databases --master-data --single-transaction > all_databases.sql
This backup acquires a global read lock on all tables (using 'FLUSH TABLES WITH READ LOCK') at the beginning of the dump. As soon as this lock has been acquired, the binary log coordinates are read and the lock is released. If long updating statements are running when the *note 'FLUSH': flush. statement is issued, the MySQL server may get stalled until those statements finish. After that, the dump becomes lock free and does not disturb reads and writes on the tables. If the update statements that the MySQL server receives are short (in terms of execution time), the initial lock period should not be noticeable, even with many updates.
For point-in-time recovery (also known as 'roll-forward,' when you need to restore an old backup and replay the changes that happened since that backup), it is often useful to rotate the binary log (see *note binary-log::) or at least know the binary log coordinates to which the dump corresponds:
mysqldump --all-databases --master-data=2 > all_databases.sql
Or:
mysqldump --all-databases --flush-logs --master-data=2 > all_databases.sql
The '--master-data' and '--single-transaction' options can be used simultaneously, which provides a convenient way to make an online backup suitable for use prior to point-in-time recovery if tables are stored using the 'InnoDB' storage engine.
For more information on making backups, see note backup-methods::, and note backup-strategy-example::.
To select the effect of '--opt' except for some features, use the '--skip' option for each feature. To disable extended inserts and memory buffering, use '--opt' '--skip-extended-insert' '--skip-quick'. (Actually, '--skip-extended-insert' '--skip-quick' is sufficient because '--opt' is on by default.)
To reverse '--opt' for all features except index disabling and table locking, use '--skip-opt' '--disable-keys' '--lock-tables'.
Restrictions
*note 'mysqldump': mysqldump. does not dump the 'INFORMATION_SCHEMA', 'performance_schema', or 'sys' schema by default. To dump any of these, name them explicitly on the command line. You can also name them with the '--databases' option. For 'INFORMATION_SCHEMA' and 'performance_schema', also use the '--skip-lock-tables' option.
note 'mysqldump': mysqldump. does not dump the NDB Cluster note 'ndbinfo': mysql-cluster-ndbinfo. information database.
note 'mysqldump': mysqldump. does not dump 'InnoDB' note 'CREATE TABLESPACE': create-tablespace. statements.
note 'mysqldump': mysqldump. always strips the 'NO_AUTO_CREATE_USER' SQL mode as 'NO_AUTO_CREATE_USER' is not compatible with MySQL 8.0. It remains stripped even when importing back into MySQL 5.7, which means that stored routines could behave differently after restoring a dump if they rely upon this particular sql_mode. It is stripped as of note 'mysqldump': mysqldump. 5.7.24.
It is not recommended to restore from a dump made using note 'mysqldump': mysqldump. to a MySQL 5.6.9 or earlier server that has GTIDs enabled. See note replication-gtids-restrictions::.
*note 'mysqldump': mysqldump. includes statements to recreate the 'general_log' and 'slow_query_log' tables for dumps of the 'mysql' database. Log table contents are not dumped.
If you encounter problems backing up views due to insufficient privileges, see *note view-restrictions:: for a workaround.
File: manual.info.tmp, Node: mysqlimport, Next: mysqlpump, Prev: mysqldump, Up: programs-client
The note 'mysqlimport': mysqlimport. client provides a command-line interface to the note 'LOAD DATA': load-data. SQL statement. Most options to note 'mysqlimport': mysqlimport. correspond directly to clauses of note 'LOAD DATA': load-data. syntax. See *note load-data::.
Invoke *note 'mysqlimport': mysqlimport. like this:
mysqlimport [OPTIONS] DB_NAME TEXTFILE1 [TEXTFILE2 ...]
For each text file named on the command line, *note 'mysqlimport': mysqlimport. strips any extension from the file name and uses the result to determine the name of the table into which to import the file's contents. For example, files named 'patient.txt', 'patient.text', and 'patient' all would be imported into a table named 'patient'.
note 'mysqlimport': mysqlimport. supports the following options, which can be specified on the command line or in the '[mysqlimport]' and '[client]' groups of an option file. For information about option files used by MySQL programs, see note option-files::.
mysqlimport Options
Option Name Description IntroducedDeprecated
-bind-address
Use specified network interface to connect to MySQL Server
-character-sets-dir
Directory where character sets can be found
-columns
This option takes a comma-separated list of column names as its value
-compress
Compress all information sent between client and server
-debug
Write debugging log
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-default-character-set
Specify default character set
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-delete
Empty the table before importing the text file
-enable-cleartext-plugin
Enable cleartext 5.7.10 authentication
plugin
-fields-enclosed-by
This option has the same meaning as the corresponding clause for LOAD DATA
-fields-escaped-by
This option has the same meaning as the corresponding clause for LOAD DATA
-fields-optionally-enclosed-by
This option has the same meaning as the corresponding clause for LOAD DATA
-fields-terminated-by
This option has the same meaning as the corresponding clause for LOAD DATA
-force
Continue even if an SQL error occurs
-get-server-public-key
Request RSA 5.7.23 public key from
server
-help
Display help message and exit
-host
Host on which MySQL server is located
-ignore
See the description for the -replace option
-ignore-lines
Ignore the first N lines of the data file
-lines-terminated-by
This option has the same meaning as the corresponding clause for LOAD DATA
-local
Read input files locally from the client host
-lock-tables
Lock all tables for writing before processing any text files
-login-path
Read login path options from .mylogin.cnf
-low-priority
Use LOW_PRIORITY when loading the table
-no-defaults
Read no option files
-password
Password to use when connecting to server
-pipe
Connect to server using named pipe (Windows only)
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-print-defaults
Print default options
-protocol
Transport protocol to use
-replace
The -replace and -ignore options control handling of input rows that duplicate existing rows on unique key values
-secure-auth
Do not send Yes passwords to
server in old (pre-4.1) format
-server-public-key-path
Path name to file 5.7.23 containing RSA
public key
-shared-memory-base-name
Shared-memory name for shared-memory connections (Windows only)
-silent
Produce output only when errors occur
-socket
Unix socket file or Windows named pipe to use
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of
connection to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-use-threads
Number of threads for parallel file-loading
-user
MySQL user name to use when connecting to server
-verbose
Verbose mode
-version
Display version information and exit
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--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=path'
Type
String
Default Value
'[none]'
The directory where character sets are installed. See *note charset-configuration::.
'--columns=COLUMN_LIST', '-c COLUMN_LIST'
Command-Line Format
'--columns=column_list'
This option takes a list of comma-separated column names as its value. The order of the column names indicates how to match data file columns with table columns.
'--compress', '-C'
Command-Line Format
'--compress[={OFF|ON}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note connection-compression-control::.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:o'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default is 'd:t:o'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--default-character-set=CHARSET_NAME'
Command-Line Format
'--default-character-set=charset_name'
Type
String
Use CHARSET_NAME as the default character set. See *note charset-configuration::.
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysqlimport': mysqlimport. normally reads the '[client]' and '[mysqlimport]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysqlimport': mysqlimport. also reads the '[client_other]' and '[mysqlimport_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--delete', '-D'
Command-Line Format
'--delete'
Empty the table before importing the text file.
'--enable-cleartext-plugin'
Command-Line Format
'--enable-cleartext-plugin'
Introduced
5.7.10
Type
Boolean
Default Value
'FALSE'
Enable the 'mysql_clear_password' cleartext authentication plugin. (See *note cleartext-pluggable-authentication::.)
This option was added in MySQL 5.7.10.
'--fields-terminated-by=...', '--fields-enclosed-by=...', '--fields-optionally-enclosed-by=...', '--fields-escaped-by=...'
Command-Line Format
'--fields-terminated-by=string'
Type
String
Command-Line Format
'--fields-enclosed-by=string'
Type
String
Command-Line Format
'--fields-optionally-enclosed-by=string'
Type
String
Command-Line Format
'--fields-escaped-by'
Type
String
These options have the same meaning as the corresponding clauses for note 'LOAD DATA': load-data. See note load-data::.
'--force', '-f'
Command-Line Format
'--force'
Ignore errors. For example, if a table for a text file does not exist, continue processing any remaining files. Without '--force', *note 'mysqlimport': mysqlimport. exits if a table does not exist.
'--get-server-public-key'
Command-Line Format
'--get-server-public-key'
Introduced
5.7.23
Type
Boolean
Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the 'caching_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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host=host_name'
Type
String
Default Value
'localhost'
Import data to the MySQL server on the given host. The default host is 'localhost'.
'--ignore', '-i'
Command-Line Format
'--ignore'
See the description for the '--replace' option.
'--ignore-lines=N'
Command-Line Format
'--ignore-lines=#'
Type
Numeric
Ignore the first N lines of the data file.
'--lines-terminated-by=...'
Command-Line Format
'--lines-terminated-by=string'
Type
String
This option has the same meaning as the corresponding clause for note 'LOAD DATA': load-data. For example, to import Windows files that have lines terminated with carriage return/linefeed pairs, use '--lines-terminated-by=""'. (You might have to double the backslashes, depending on the escaping conventions of your command interpreter.) See note load-data::.
'--local', '-L'
Command-Line Format
'--local'
Type
Boolean
Default Value
'FALSE'
By default, files are read by the server on the server host. With this option, *note 'mysqlimport': mysqlimport. reads input files locally on the client host.
Successful use of 'LOCAL' load operations within note 'mysqlimport': mysqlimport. also requires that the server permits local loading; see note load-data-local-security::
'--lock-tables', '-l'
Command-Line Format
'--lock-tables'
Lock all tables for writing before processing any text files. This ensures that all tables are synchronized on the server.
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--low-priority'
Command-Line Format
'--low-priority'
Use 'LOW_PRIORITY' when loading the table. This affects only storage engines that use only table-level locking (such as 'MyISAM', 'MEMORY', and 'MERGE').
'--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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysqlimport': mysqlimport. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysqlimport': mysqlimport. should not prompt for one, use the '--skip-password' option.
'--pipe', '-W'
Command-Line Format
'--pipe'
Type
String
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the 'named_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 the 'named_pipe_full_access_group' system variable.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysqlimport': mysqlimport. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
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, see *note option-file-options::.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note transport-protocols::.
'--replace', '-r'
Command-Line Format
'--replace'
The '--replace' and '--ignore' options control handling of input rows that duplicate existing rows on unique key values. If you specify '--replace', new rows replace existing rows that have the same unique key value. If you specify '--ignore', input rows that duplicate an existing row on a unique key value are skipped. If you do not specify either option, an error occurs when a duplicate key value is found, and the rest of the text file is ignored.
'--secure-auth'
Command-Line Format
'--secure-auth'
Deprecated
Yes
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, see *note account-upgrades::.
'--server-public-key-path=FILE_NAME'
Command-Line Format
'--server-public-key-path=file_name'
Introduced
5.7.23
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
The '--server-public-key-path' option was added in MySQL 5.7.23.
'--shared-memory-base-name=NAME'
Command-Line Format
'--shared-memory-base-name=name'
Platform Specific
Windows
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 'MYSQL'. The shared-memory name is case-sensitive.
This option applies only if the server was started with the 'shared_memory' system variable enabled to support shared-memory connections.
'--silent', '-s'
Command-Line Format
'--silent'
Silent mode. Produce output only when errors occur.
'--socket=PATH', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_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. See *note encrypted-connection-options::.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-ciphers::.
This option was added in MySQL 5.7.10.
'--user=USER_NAME', '-u USER_NAME'
Command-Line Format
'--user=user_name,'
Type
String
The user name of the MySQL account to use for connecting to the server.
'--use-threads=N'
Command-Line Format
'--use-threads=#'
Type
Numeric
Load files in parallel using N threads.
'--verbose', '-v'
Command-Line Format
'--verbose'
Verbose mode. Print more information about what the program does.
'--version', '-V'
Command-Line Format
'--version'
Display version information and exit.
Here is a sample session that demonstrates use of *note 'mysqlimport': mysqlimport.:
$> mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
$> ed
a
100 Max Sydow
101 Count Dracula
.
w imptest.txt
32
q
$> od -c imptest.txt
0000000 1 0 0 \t M a x S y d o w \n 1 0
0000020 1 \t C o u n t D r a c u l a \n
0000040
$> mysqlimport --local test imptest.txt
test.imptest: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
$> mysql -e 'SELECT * FROM imptest' test
+------+---------------+
| id | n |
+------+---------------+
| 100 | Max Sydow |
| 101 | Count Dracula |
+------+---------------+
File: manual.info.tmp, Node: mysqlpump, Next: mysqlshow, Prev: mysqlimport, Up: programs-client
*note mysqlpump-syntax::
*note mysqlpump-option-summary::
*note mysqlpump-options::
*note mysqlpump-filtering::
*note mysqlpump-parallelism::
*note mysqlpump-restrictions::
The *note 'mysqlpump': mysqlpump. client utility performs logical backups, producing a set of SQL statements that can be executed to reproduce the original database object definitions and table data. It dumps one or more MySQL databases for backup or transfer to another SQL server.
*note 'mysqlpump': mysqlpump. features include:
Parallel processing of databases, and of objects within databases, to speed up the dump process
Better control over which databases and database objects (tables, stored programs, user accounts) to dump
Dumping of user accounts as account-management statements (note 'CREATE USER': create-user, note 'GRANT': grant.) rather than as inserts into the 'mysql' system database
Capability of creating compressed output
Progress indicator (the values are estimates)
For dump file reloading, faster secondary index creation for 'InnoDB' tables by adding indexes after rows are inserted
*note 'mysqlpump': mysqlpump. requires at least the 'SELECT' privilege for dumped tables, 'SHOW VIEW' for dumped views, 'TRIGGER' for dumped triggers, and 'LOCK TABLES' if the '--single-transaction' option is not used. The 'SELECT' privilege on the 'mysql' system database is required to dump user definitions. Certain options might require other privileges as noted in the option descriptions.
To reload a dump file, you must have the privileges required to execute the statements that it contains, such as the appropriate 'CREATE' privileges for objects created by those statements.
Note:
A dump made using PowerShell on Windows with output redirection creates a file that has UTF-16 encoding:
mysqlpump [options] > dump.sql
However, UTF-16 is not permitted as a connection character set (see *note charset-connection::), so the dump file does not load correctly. To work around this issue, use the '--result-file' option, which creates the output in ASCII format:
mysqlpump [options] --result-file=dump.sql
mysqlpump Invocation Syntax
By default, note 'mysqlpump': mysqlpump. dumps all databases (with certain exceptions noted in note mysqlpump-restrictions::). To specify this behavior explicitly, use the '--all-databases' option:
mysqlpump --all-databases
To dump a single database, or certain tables within that database, name the database on the command line, optionally followed by table names:
mysqlpump DB_NAME
mysqlpump DB_NAME TBL_NAME1 TBL_NAME2 ...
To treat all name arguments as database names, use the '--databases' option:
mysqlpump --databases DB_NAME1 DB_NAME2 ...
By default, note 'mysqlpump': mysqlpump. does not dump user account definitions, even if you dump the 'mysql' system database that contains the grant tables. To dump grant table contents as logical definitions in the form of note 'CREATE USER': create-user. and *note 'GRANT': grant. statements, use the '--users' option and suppress all database dumping:
mysqlpump --exclude-databases=% --users
In the preceding command, '%' is a wildcard that matches all database names for the '--exclude-databases' option.
note 'mysqlpump': mysqlpump. supports several options for including or excluding databases, tables, stored programs, and user definitions. See note mysqlpump-filtering::.
To reload a dump file, execute the statements that it contains. For example, use the *note 'mysql': mysql. client:
mysqlpump [options] > dump.sql
mysql < dump.sql
The following discussion provides additional *note 'mysqlpump': mysqlpump. usage examples.
To see a list of the options note 'mysqlpump': mysqlpump. supports, issue the command note 'mysqlpump --help': mysqlpump.
mysqlpump Option Summary
note 'mysqlpump': mysqlpump. supports the following options, which can be specified on the command line or in the '[mysqlpump]' and '[client]' groups of an option file. (Prior to MySQL 5.7.30, note 'mysqlpump': mysqlpump. read the '[mysql_dump]' group rather than '[mysqlpump]'. As of 5.7.30, '[mysql_dump]' is still accepted but is deprecated.) For information about option files used by MySQL programs, see *note option-files::.
mysqlpump Options
Option Name Description Introduced
-add-drop-database
Add DROP DATABASE statement before each CREATE DATABASE statement
-add-drop-table
Add DROP TABLE statement before each CREATE TABLE statement
-add-drop-user
Add DROP USER statement before each CREATE USER statement
-add-locks
Surround each table dump with LOCK TABLES and UNLOCK TABLES statements
-all-databases
Dump all databases
-bind-address
Use specified network interface to connect to MySQL Server
-character-sets-dir
Directory where character sets are installed
-complete-insert
Use complete INSERT statements that include column names
-compress
Compress all information sent between client and server
-compress-output
Output compression algorithm
-databases
Interpret all name arguments as database names
-debug
Write debugging log
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-default-character-set
Specify default character set
-default-parallelism
Default number of threads for parallel processing
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-defer-table-indexes
For reloading, defer index creation until after loading table rows
-events
Dump events from dumped databases
-exclude-databases
Databases to exclude from dump
-exclude-events
Events to exclude from dump
-exclude-routines
Routines to exclude from dump
-exclude-tables
Tables to exclude from dump
-exclude-triggers
Triggers to exclude from dump
-exclude-users
Users to exclude from dump
-extended-insert
Use multiple-row INSERT syntax
-get-server-public-key
Request RSA public 5.7.23 key from server
-help
Display help message and exit
-hex-blob
Dump binary columns using hexadecimal notation
-host
Host on which MySQL server is located
-include-databases
Databases to include in dump
-include-events
Events to include in dump
-include-routines
Routines to include in dump
-include-tables
Tables to include in dump
-include-triggers
Triggers to include in dump
-include-users
Users to include in dump
-insert-ignore
Write INSERT IGNORE rather than INSERT statements
-log-error-file
Append warnings and errors to named file
-login-path
Read login path options from .mylogin.cnf
-max-allowed-packet
Maximum packet length to send to or receive from server
-net-buffer-length
Buffer size for TCP/IP and socket communication
-no-create-db
Do not write CREATE DATABASE statements
-no-create-info
Do not write CREATE TABLE statements that re-create each dumped table
-no-defaults
Read no option files
-parallel-schemas
Specify schema-processing parallelism
-password
Password to use when connecting to server
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-print-defaults
Print default options
-protocol
Transport protocol to use
-replace
Write REPLACE statements rather than INSERT statements
-result-file
Direct output to a given file
-routines
Dump stored routines (procedures and functions) from dumped databases
-secure-auth
Do not send passwords to server in old (pre-4.1) format
-server-public-key-path
Path name to file 5.7.23 containing RSA
public key
-set-charset
Add SET NAMES default_character_set to output
-set-gtid-purged
Whether to add SET 5.7.18 @@GLOBAL.GTID_PURGED
to output
-single-transaction
Dump tables within single transaction
-skip-definer
Omit DEFINER and SQL SECURITY clauses from view and stored program CREATE statements
-skip-dump-rows
Do not dump table rows
-socket
Unix socket file or Windows named pipe to use
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of connection
to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-triggers
Dump triggers for each dumped table
-tz-utc
Add SET TIME_ZONE='+00:00' to dump file
-user
MySQL user name to use when connecting to server
-users
Dump user accounts
-version
Display version information and exit
-watch-progress
Display progress indicator
mysqlpump Option Descriptions
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--add-drop-database'
Command-Line Format
'--add-drop-database'
Write a note 'DROP DATABASE': drop-database. statement before each note 'CREATE DATABASE': create-database. statement.
'--add-drop-table'
Command-Line Format
'--add-drop-table'
Write a note 'DROP TABLE': drop-table. statement before each note 'CREATE TABLE': create-table. statement.
'--add-drop-user'
Command-Line Format
'--add-drop-user'
Write a note 'DROP USER': drop-user. statement before each note 'CREATE USER': create-user. statement.
'--add-locks'
Command-Line Format
'--add-locks'
Surround each table dump with note 'LOCK TABLES': lock-tables. and note 'UNLOCK TABLES': lock-tables. statements. This results in faster inserts when the dump file is reloaded. See *note insert-optimization::.
This option does not work with parallelism because note 'INSERT': insert. statements from different tables can be interleaved and note 'UNLOCK TABLES': lock-tables. following the end of the inserts for one table could release locks on tables for which inserts remain.
'--add-locks' and '--single-transaction' are mutually exclusive.
'--all-databases', '-A'
Command-Line Format
'--all-databases'
Dump all databases (with certain exceptions noted in *note mysqlpump-restrictions::). This is the default behavior if no other is specified explicitly.
'--all-databases' and '--databases' are mutually exclusive.
'--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=PATH'
Command-Line Format
'--character-sets-dir=dir_name'
Type
Directory name
The directory where character sets are installed. See *note charset-configuration::.
'--complete-insert'
Command-Line Format
'--complete-insert'
Write complete *note 'INSERT': insert. statements that include column names.
'--compress', '-C'
Command-Line Format
'--compress[={OFF|ON}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note connection-compression-control::.
'--compress-output=ALGORITHM'
Command-Line Format
'--compress-output=algorithm'
Type
Enumeration
Valid Values
'LZ4' 'ZLIB'
By default, *note 'mysqlpump': mysqlpump. does not compress output. This option specifies output compression using the specified algorithm. Permitted algorithms are 'LZ4' and 'ZLIB'.
To uncompress compressed output, you must have an appropriate utility. If the system commands 'lz4' and 'openssl zlib' are not available, as of MySQL 5.7.10, MySQL distributions include note 'lz4_decompress': lz4-decompress. and note 'zlib_decompress': zlib-decompress. utilities that can be used to decompress note 'mysqlpump': mysqlpump. output that was compressed using the '--compress-output=LZ4' and '--compress-output=ZLIB' options. For more information, see note lz4-decompress::, and *note zlib-decompress::.
Alternatives include the 'lz4' and 'openssl' commands, if they are installed on your system. For example, 'lz4' can uncompress 'LZ4' output:
lz4 -d INPUT_FILE OUTPUT_FILE
'ZLIB' output can be uncompresed like this:
openssl zlib -d < INPUT_FILE > OUTPUT_FILE
'--databases', '-B'
Command-Line Format
'--databases'
Normally, note 'mysqlpump': mysqlpump. treats the first name argument on the command line as a database name and any following names as table names. With this option, it treats all name arguments as database names. note 'CREATE DATABASE': create-database. statements are included in the output before each new database.
'--all-databases' and '--databases' are mutually exclusive.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:O,/tmp/mysqlpump.trace'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default is 'd:t:O,/tmp/mysqlpump.trace'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info', '-T'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--default-character-set=CHARSET_NAME'
Command-Line Format
'--default-character-set=charset_name'
Type
String
Default Value
'utf8'
Use CHARSET_NAME as the default character set. See note charset-configuration::. If no character set is specified, note 'mysqlpump': mysqlpump. uses 'utf8'.
'--default-parallelism=N'
Command-Line Format
'--default-parallelism=N'
Type
Integer
Default Value
'2'
The default number of threads for each parallel processing queue. The default is 2.
The '--parallel-schemas' option also affects parallelism and can be used to override the default number of threads. For more information, see *note mysqlpump-parallelism::.
With '--default-parallelism=0' and no '--parallel-schemas' options, *note 'mysqlpump': mysqlpump. runs as a single-threaded process and creates no queues.
With parallelism enabled, it is possible for output from different databases to be interleaved.
Note:
Before MySQL 5.7.11, use of the '--single-transaction' option is mutually exclusive with parallelism. To use '--single-transaction', disable parallelism by setting '--default-parallelism' to 0 and not using any instances of '--parallel-schemas':
mysqlpump --single-transaction --default-parallelism=0
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysqlpump': mysqlpump. normally reads the '[client]' and '[mysqlpump]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysqlpump': mysqlpump. also reads the '[client_other]' and '[mysqlpump_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--defer-table-indexes'
Command-Line Format
'--defer-table-indexes'
Type
Boolean
Default Value
'TRUE'
In the dump output, defer index creation for each table until after its rows have been loaded. This works for all storage engines, but for 'InnoDB' applies only for secondary indexes.
This option is enabled by default; use '--skip-defer-table-indexes' to disable it.
'--events'
Command-Line Format
'--events'
Type
Boolean
Default Value
'TRUE'
Include Event Scheduler events for the dumped databases in the output. Event dumping requires the 'EVENT' privileges for those databases.
The output generated by using '--events' contains *note 'CREATE EVENT': create-event. statements to create the events. However, these statements do not include attributes such as the event creation and modification timestamps, so when the events are reloaded, they are created with timestamps equal to the reload time.
If you require events to be created with their original timestamp attributes, do not use '--events'. Instead, dump and reload the contents of the 'mysql.event' table directly, using a MySQL account that has appropriate privileges for the 'mysql' database.
This option is enabled by default; use '--skip-events' to disable it.
'--exclude-databases=DB_LIST'
Command-Line Format
'--exclude-databases=db_list'
Type
String
Do not dump the databases in DB_LIST, which is a list of one or more comma-separated database names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--exclude-events=EVENT_LIST'
Command-Line Format
'--exclude-events=event_list'
Type
String
Do not dump the databases in EVENT_LIST, which is a list of one or more comma-separated event names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--exclude-routines=ROUTINE_LIST'
Command-Line Format
'--exclude-routines=routine_list'
Type
String
Do not dump the events in ROUTINE_LIST, which is a list of one or more comma-separated routine (stored procedure or function) names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--exclude-tables=TABLE_LIST'
Command-Line Format
'--exclude-tables=table_list'
Type
String
Do not dump the tables in TABLE_LIST, which is a list of one or more comma-separated table names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--exclude-triggers=TRIGGER_LIST'
Command-Line Format
'--exclude-triggers=trigger_list'
Type
String
Do not dump the triggers in TRIGGER_LIST, which is a list of one or more comma-separated trigger names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--exclude-users=USER_LIST'
Command-Line Format
'--exclude-users=user_list'
Type
String
Do not dump the user accounts in USER_LIST, which is a list of one or more comma-separated account names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--extended-insert=N'
Command-Line Format
'--extended-insert=N'
Write *note 'INSERT': insert. statements using multiple-row syntax that includes several 'VALUES' lists. This results in a smaller dump file and speeds up inserts when the file is reloaded.
The option value indicates the number of rows to include in each note 'INSERT': insert. statement. The default is 250. A value of 1 produces one note 'INSERT': insert. statement per table row.
'--get-server-public-key'
Command-Line Format
'--get-server-public-key'
Introduced
5.7.23
Type
Boolean
Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the 'caching_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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--hex-blob'
Command-Line Format
'--hex-blob'
Dump binary columns using hexadecimal notation (for example, ''abc'' becomes '0x616263'). The affected data types are note 'BINARY': binary-varbinary, note 'VARBINARY': binary-varbinary, note 'BLOB': blob. types, note 'BIT': bit-type, all spatial data types, and other non-binary data types when used with the *note 'binary' character set: charset-binary-set.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host'
Dump data from the MySQL server on the given host.
'--include-databases=DB_LIST'
Command-Line Format
'--include-databases=db_list'
Type
String
Dump the databases in DB_LIST, which is a list of one or more comma-separated database names. The dump includes all objects in the named databases. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--include-events=EVENT_LIST'
Command-Line Format
'--include-events=event_list'
Type
String
Dump the events in EVENT_LIST, which is a list of one or more comma-separated event names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--include-routines=ROUTINE_LIST'
Command-Line Format
'--include-routines=routine_list'
Type
String
Dump the routines in ROUTINE_LIST, which is a list of one or more comma-separated routine (stored procedure or function) names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--include-tables=TABLE_LIST'
Command-Line Format
'--include-tables=table_list'
Type
String
Dump the tables in TABLE_LIST, which is a list of one or more comma-separated table names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--include-triggers=TRIGGER_LIST'
Command-Line Format
'--include-triggers=trigger_list'
Type
String
Dump the triggers in TRIGGER_LIST, which is a list of one or more comma-separated trigger names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--include-users=USER_LIST'
Command-Line Format
'--include-users=user_list'
Type
String
Dump the user accounts in USER_LIST, which is a list of one or more comma-separated user names. Multiple instances of this option are additive. For more information, see *note mysqlpump-filtering::.
'--insert-ignore'
Command-Line Format
'--insert-ignore'
Write note 'INSERT IGNORE': insert. statements rather than note 'INSERT': insert. statements.
'--log-error-file=FILE_NAME'
Command-Line Format
'--log-error-file=file_name'
Type
File name
Log warnings and errors by appending them to the named file. If this option is not given, *note 'mysqlpump': mysqlpump. writes warnings and errors to the standard error output.
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--max-allowed-packet=N'
Command-Line Format
'--max-allowed-packet=N'
Type
Numeric
Default Value
'25165824'
The maximum size of the buffer for client/server communication. The default is 24MB, the maximum is 1GB.
'--net-buffer-length=N'
Command-Line Format
'--net-buffer-length=N'
Type
Numeric
Default Value
'1047552'
The initial size of the buffer for client/server communication. When creating multiple-row note 'INSERT': insert. statements (as with the '--extended-insert' option), note 'mysqlpump': mysqlpump. creates rows up to N bytes long. If you use this option to increase the value, ensure that the MySQL server 'net_buffer_length' system variable has a value at least this large.
'--no-create-db'
Command-Line Format
'--no-create-db'
Suppress any *note 'CREATE DATABASE': create-database. statements that might otherwise be included in the output.
'--no-create-info', '-t'
Command-Line Format
'--no-create-info'
Do not write *note 'CREATE TABLE': create-table. statements that create each dumped table.
'--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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--parallel-schemas=[N:]DB_LIST'
Command-Line Format
'--parallel-schemas=[N:]schema_list'
Type
String
Create a queue for processing the databases in DB_LIST, which is a list of one or more comma-separated database names. If N is given, the queue uses N threads. If N is not given, the '--default-parallelism' option determines the number of queue threads.
Multiple instances of this option create multiple queues. note 'mysqlpump': mysqlpump. also creates a default queue to use for databases not named in any '--parallel-schemas' option, and for dumping user definitions if command options select them. For more information, see note mysqlpump-parallelism::.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysqlpump': mysqlpump. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysqlpump': mysqlpump. should not prompt for one, use the '--skip-password' option.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysqlpump': mysqlpump. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
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, see *note option-file-options::.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note transport-protocols::.
'--replace'
Command-Line Format
'--replace'
Write note 'REPLACE': replace. statements rather than note 'INSERT': insert. statements.
'--result-file=FILE_NAME'
Command-Line Format
'--result-file=file_name'
Type
File name
Direct output to the named file. The result file is created and its previous contents overwritten, even if an error occurs while generating the dump.
This option should be used on Windows to prevent newline '' characters from being converted to '' carriage return/newline sequences.
'--routines'
Command-Line Format
'--routines'
Type
Boolean
Default Value
'TRUE'
Include stored routines (procedures and functions) for the dumped databases in the output. This option requires the 'SELECT' privilege for the 'mysql.proc' table.
The output generated by using '--routines' contains note 'CREATE PROCEDURE': create-procedure. and note 'CREATE FUNCTION': create-function. statements to create the routines. However, these statements do not include attributes such as the routine creation and modification timestamps, so when the routines are reloaded, they are created with timestamps equal to the reload time.
If you require routines to be created with their original timestamp attributes, do not use '--routines'. Instead, dump and reload the contents of the 'mysql.proc' table directly, using a MySQL account that has appropriate privileges for the 'mysql' database.
This option is enabled by default; use '--skip-routines' to disable it.
'--secure-auth'
Command-Line Format
'--secure-auth'
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.
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.
'--server-public-key-path=FILE_NAME'
Command-Line Format
'--server-public-key-path=file_name'
Introduced
5.7.23
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
The '--server-public-key-path' option was added in MySQL 5.7.23.
'--set-charset'
Command-Line Format
'--set-charset'
Write *note 'SET NAMES DEFAULT_CHARACTER_SET': set-names. to the output.
This option is enabled by default. To disable it and suppress the *note 'SET NAMES': set-names. statement, use '--skip-set-charset'.
'--set-gtid-purged=VALUE'
Command-Line Format
'--set-gtid-purged=value'
Introduced
5.7.18
Type
Enumeration
Default Value
'AUTO'
Valid Values
'OFF' 'ON' 'AUTO'
This option enables control over global transaction ID (GTID) information written to the dump file, by indicating whether to add a *note 'SET @@GLOBAL.gtid_purged': set-variable. statement to the output. This option may also cause a statement to be written to the output that disables binary logging while the dump file is being reloaded.
The following table shows the permitted option values. The default value is 'AUTO'.
Value Meaning
'OFF' Add no 'SET' statement to the output.
'ON' Add a 'SET' statement to the output. An error occurs if GTIDs are not enabled on the server.
'AUTO' Add a 'SET' statement to the output if GTIDs are enabled on the server.
The '--set-gtid-purged' option has the following effect on binary logging when the dump file is reloaded:
* '--set-gtid-purged=OFF': 'SET @@SESSION.SQL_LOG_BIN=0;' is not
added to the output.
* '--set-gtid-purged=ON': 'SET @@SESSION.SQL_LOG_BIN=0;' is
added to the output.
* '--set-gtid-purged=AUTO': 'SET @@SESSION.SQL_LOG_BIN=0;' is
added to the output if GTIDs are enabled on the server you are
backing up (that is, if 'AUTO' evaluates to 'ON').
This option was added in MySQL 5.7.18.
'--single-transaction'
Command-Line Format
'--single-transaction'
This option sets the transaction isolation mode to 'REPEATABLE READ' and sends a note 'START TRANSACTION': commit. SQL statement to the server before dumping data. It is useful only with transactional tables such as 'InnoDB', because then it dumps the consistent state of the database at the time when note 'START TRANSACTION': commit. was issued without blocking any applications.
When using this option, you should keep in mind that only 'InnoDB' tables are dumped in a consistent state. For example, any 'MyISAM' or 'MEMORY' tables dumped while using this option may still change state.
While a '--single-transaction' dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates), no other connection should use the following statements: note 'ALTER TABLE': alter-table, note 'CREATE TABLE': create-table, note 'DROP TABLE': drop-table, note 'RENAME TABLE': rename-table, note 'TRUNCATE TABLE': truncate-table. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause the note 'SELECT': select. that is performed by *note 'mysqlpump': mysqlpump. to retrieve the table contents to obtain incorrect contents or fail.
'--add-locks' and '--single-transaction' are mutually exclusive.
Note:
Before MySQL 5.7.11, use of the '--single-transaction' option is mutually exclusive with parallelism. To use '--single-transaction', disable parallelism by setting '--default-parallelism' to 0 and not using any instances of '--parallel-schemas':
mysqlpump --single-transaction --default-parallelism=0
'--skip-definer'
Command-Line Format
'--skip-definer'
Type
Boolean
Default Value
'FALSE'
Omit 'DEFINER' and 'SQL SECURITY' clauses from the 'CREATE' statements for views and stored programs. The dump file, when reloaded, creates objects that use the default 'DEFINER' and 'SQL SECURITY' values. See *note stored-objects-security::.
'--skip-dump-rows', '-d'
Command-Line Format
'--skip-dump-rows'
Type
Boolean
Default Value
'FALSE'
Do not dump table rows.
'--socket=PATH', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_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. See *note encrypted-connection-options::.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-ciphers::.
This option was added in MySQL 5.7.10.
'--triggers'
Command-Line Format
'--triggers'
Type
Boolean
Default Value
'TRUE'
Include triggers for each dumped table in the output.
This option is enabled by default; use '--skip-triggers' to disable it.
'--tz-utc'
Command-Line Format
'--tz-utc'
This option enables note 'TIMESTAMP': datetime. columns to be dumped and reloaded between servers in different time zones. note 'mysqlpump': mysqlpump. sets its connection time zone to UTC and adds 'SET TIME_ZONE='+00:00'' to the dump file. Without this option, *note 'TIMESTAMP': datetime. columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change if the servers are in different time zones. '--tz-utc' also protects against changes due to daylight saving time.
This option is enabled by default; use '--skip-tz-utc' to disable it.
'--user=USER_NAME', '-u USER_NAME'
Command-Line Format
'--user=user_name'
Type
String
The user name of the MySQL account to use for connecting to the server.
'--users'
Command-Line Format
'--users'
Type
Boolean
Default Value
'FALSE'
Dump user accounts as logical definitions in the form of note 'CREATE USER': create-user. and note 'GRANT': grant. statements.
User definitions are stored in the grant tables in the 'mysql' system database. By default, *note 'mysqlpump': mysqlpump. does not include the grant tables in 'mysql' database dumps. To dump the contents of the grant tables as logical definitions, use the '--users' option and suppress all database dumping:
mysqlpump --exclude-databases=% --users
'--version', '-V'
Command-Line Format
'--version'
Display version information and exit.
'--watch-progress'
Command-Line Format
'--watch-progress'
Type
Boolean
Default Value
'TRUE'
Periodically display a progress indicator that provides information about the completed and total number of tables, rows, and other objects.
This option is enabled by default; use '--skip-watch-progress' to disable it.
mysqlpump Object Selection
*note 'mysqlpump': mysqlpump. has a set of inclusion and exclusion options that enable filtering of several object types and provide flexible control over which objects to dump:
'--include-databases' and '--exclude-databases' apply to databases and all objects within them.
'--include-tables' and '--exclude-tables' apply to tables. These options also affect triggers associated with tables unless the trigger-specific options are given.
'--include-triggers' and '--exclude-triggers' apply to triggers.
'--include-routines' and '--exclude-routines' apply to stored procedures and functions. If a routine option matches a stored procedure name, it also matches a stored function of the same name.
'--include-events' and '--exclude-events' apply to Event Scheduler events.
'--include-users' and '--exclude-users' apply to user accounts.
Any inclusion or exclusion option may be given multiple times. The effect is additive. Order of these options does not matter.
The value of each inclusion and exclusion option is a list of comma-separated names of the appropriate object type. For example:
--exclude-databases=test,world
--include-tables=customer,invoice
Wildcard characters are permitted in the object names:
'%' matches any sequence of zero or more characters.
'_' matches any single character.
For example, '--include-tables=t%,__tmp' matches all table names that begin with 't' and all five-character table names that end with 'tmp'.
For users, a name specified without a host part is interpreted with an implied host of '%'. For example, 'u1' and 'u1@%' are equivalent. This is the same equivalence that applies in MySQL generally (see *note account-names::).
Inclusion and exclusion options interact as follows:
By default, with no inclusion or exclusion options, note 'mysqlpump': mysqlpump. dumps all databases (with certain exceptions noted in note mysqlpump-restrictions::).
If inclusion options are given in the absence of exclusion options, only the objects named as included are dumped.
If exclusion options are given in the absence of inclusion options, all objects are dumped except those named as excluded.
If inclusion and exclusion options are given, all objects named as excluded and not named as included are not dumped. All other objects are dumped.
If multiple databases are being dumped, it is possible to name tables, triggers, and routines in a specific database by qualifying the object names with the database name. The following command dumps databases 'db1' and 'db2', but excludes tables 'db1.t1' and 'db2.t2':
mysqlpump --include-databases=db1,db2 --exclude-tables=db1.t1,db2.t2
The following options provide alternative ways to specify which databases to dump:
The '--all-databases' option dumps all databases (with certain exceptions noted in note mysqlpump-restrictions::). It is equivalent to specifying no object options at all (the default note 'mysqlpump': mysqlpump. action is to dump everything).
'--include-databases=%' is similar to '--all-databases', but selects all databases for dumping, even those that are exceptions for '--all-databases'.
The '--databases' option causes *note 'mysqlpump': mysqlpump. to treat all name arguments as names of databases to dump. It is equivalent to an '--include-databases' option that names the same databases.
mysqlpump Parallel Processing
*note 'mysqlpump': mysqlpump. can use parallelism to achieve concurrent processing. You can select concurrency between databases (to dump multiple databases simultaneously) and within databases (to dump multiple objects from a given database simultaneously).
By default, *note 'mysqlpump': mysqlpump. sets up one queue with two threads. You can create additional queues and control the number of threads assigned to each one, including the default queue:
'--default-parallelism=N' specifies the default number of threads used for each queue. In the absence of this option, N is 2.
The default queue always uses the default number of threads. Additional queues use the default number of threads unless you specify otherwise.
'--parallel-schemas=[N:]DB_LIST' sets up a processing queue for dumping the databases named in DB_LIST and optionally specifies how many threads the queue uses. DB_LIST is a list of comma-separated database names. If the option argument begins with 'N:', the queue uses N threads. Otherwise, the '--default-parallelism' option determines the number of queue threads.
Multiple instances of the '--parallel-schemas' option create multiple queues.
Names in the database list are permitted to contain the same '%' and '_' wildcard characters supported for filtering options (see *note mysqlpump-filtering::).
*note 'mysqlpump': mysqlpump. uses the default queue for processing any databases not named explicitly with a '--parallel-schemas' option, and for dumping user definitions if command options select them.
In general, with multiple queues, note 'mysqlpump': mysqlpump. uses parallelism between the sets of databases processed by the queues, to dump multiple databases simultaneously. For a queue that uses multiple threads, note 'mysqlpump': mysqlpump. uses parallelism within databases, to dump multiple objects from a given database simultaneously. Exceptions can occur; for example, *note 'mysqlpump': mysqlpump. may block queues while it obtains from the server lists of objects in databases.
With parallelism enabled, it is possible for output from different databases to be interleaved. For example, note 'INSERT': insert. statements from multiple tables dumped in parallel can be interleaved; the statements are not written in any particular order. This does not affect reloading because output statements qualify object names with database names or are preceded by note 'USE': use. statements as required.
The granularity for parallelism is a single database object. For example, a single table cannot be dumped in parallel using multiple threads.
Examples:
mysqlpump --parallel-schemas=db1,db2 --parallel-schemas=db3
*note 'mysqlpump': mysqlpump. sets up a queue to process 'db1' and 'db2', another queue to process 'db3', and a default queue to process all other databases. All queues use two threads.
mysqlpump --parallel-schemas=db1,db2 --parallel-schemas=db3
--default-parallelism=4
This is the same as the previous example except that all queues use four threads.
mysqlpump --parallel-schemas=5:db1,db2 --parallel-schemas=3:db3
The queue for 'db1' and 'db2' uses five threads, the queue for 'db3' uses three threads, and the default queue uses the default of two threads.
As a special case, with '--default-parallelism=0' and no '--parallel-schemas' options, *note 'mysqlpump': mysqlpump. runs as a single-threaded process and creates no queues.
Note:
Before MySQL 5.7.11, use of the '--single-transaction' option is mutually exclusive with parallelism. To use '--single-transaction', disable parallelism by setting '--default-parallelism' to 0 and not using any instances of '--parallel-schemas':
mysqlpump --single-transaction --default-parallelism=0
mysqlpump Restrictions
*note 'mysqlpump': mysqlpump. does not dump the 'INFORMATION_SCHEMA', 'performance_schema', 'ndbinfo', or 'sys' schema by default. To dump any of these, name them explicitly on the command line. You can also name them with the '--databases' or '--include-databases' option.
note 'mysqlpump': mysqlpump. does not dump 'InnoDB' note 'CREATE TABLESPACE': create-tablespace. statements.
note 'mysqlpump': mysqlpump. dumps user accounts in logical form using note 'CREATE USER': create-user. and *note 'GRANT': grant. statements (for example, when you use the '--include-users' or '--users' option). For this reason, dumps of the 'mysql' system database do not by default include the grant tables that contain user definitions: 'user', 'db', 'tables_priv', 'columns_priv', 'procs_priv', or 'proxies_priv'. To dump any of the grant tables, name the 'mysql' database followed by the table names:
mysqlpump mysql user db ...
File: manual.info.tmp, Node: mysqlshow, Next: mysqlslap, Prev: mysqlpump, Up: programs-client
The *note 'mysqlshow': mysqlshow. client can be used to quickly see which databases exist, their tables, or a table's columns or indexes.
note 'mysqlshow': mysqlshow. provides a command-line interface to several SQL note 'SHOW': show. statements. See note show::. The same information can be obtained by using those statements directly. For example, you can issue them from the note 'mysql': mysql. client program.
Invoke *note 'mysqlshow': mysqlshow. like this:
mysqlshow [OPTIONS] [DB_NAME [TBL_NAME [COL_NAME]]]
If no database is given, a list of database names is shown.
If no table is given, all matching tables in the database are shown.
If no column is given, all matching columns and column types in the table are shown.
The output displays only the names of those databases, tables, or columns for which you have some privileges.
If the last argument contains shell or SQL wildcard characters ('*', '?', '%', or '_'), only those names that are matched by the wildcard are shown. If a database name contains any underscores, those should be escaped with a backslash (some Unix shells require two) to get a list of the proper tables or columns. '' and '?' characters are converted into SQL '%' and '' wildcard characters. This might cause some confusion when you try to display the columns for a table with a '' in the name, because in this case, note 'mysqlshow': mysqlshow. shows you only the table names that match the pattern. This is easily fixed by adding an extra '%' last on the command line as a separate argument.
note 'mysqlshow': mysqlshow. supports the following options, which can be specified on the command line or in the '[mysqlshow]' and '[client]' groups of an option file. For information about option files used by MySQL programs, see note option-files::.
mysqlshow Options
Option Name Description IntroducedDeprecated
-bind-address
Use specified network interface to connect to MySQL Server
-character-sets-dir
Directory where character sets can be found
-compress
Compress all information sent between client and server
-count
Show the number of rows per table
-debug
Write debugging log
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-default-character-set
Specify default character set
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-enable-cleartext-plugin
Enable cleartext 5.7.10 authentication
plugin
-get-server-public-key
Request RSA 5.7.23 public key from
server
-help
Display help message and exit
-host
Host on which MySQL server is located
-keys
Show table indexes
-login-path
Read login path options from .mylogin.cnf
-no-defaults
Read no option files
-password
Password to use when connecting to server
-pipe
Connect to server using named pipe (Windows only)
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-print-defaults
Print default options
-protocol
Transport protocol to use
-secure-auth
Do not send Yes passwords to
server in old (pre-4.1) format
-server-public-key-path
Path name to file 5.7.23 containing RSA
public key
-shared-memory-base-name
Shared-memory name for shared-memory connections (Windows only)
-show-table-type
Show a column indicating the table type
-socket
Unix socket file or Windows named pipe to use
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of
connection to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-status
Display extra information about each table
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-user
MySQL user name to use when connecting to server
-verbose
Verbose mode
-version
Display version information and exit
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--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=path'
Type
String
Default Value
'[none]'
The directory where character sets are installed. See *note charset-configuration::.
'--compress', '-C'
Command-Line Format
'--compress[={OFF|ON}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note connection-compression-control::.
'--count'
Command-Line Format
'--count'
Show the number of rows per table. This can be slow for non-'MyISAM' tables.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:o'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default is 'd:t:o'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--default-character-set=CHARSET_NAME'
Command-Line Format
'--default-character-set=charset_name'
Type
String
Use CHARSET_NAME as the default character set. See *note charset-configuration::.
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysqlshow': mysqlshow. normally reads the '[client]' and '[mysqlshow]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysqlshow': mysqlshow. also reads the '[client_other]' and '[mysqlshow_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--enable-cleartext-plugin'
Command-Line Format
'--enable-cleartext-plugin'
Introduced
5.7.10
Type
Boolean
Default Value
'FALSE'
Enable the 'mysql_clear_password' cleartext authentication plugin. (See *note cleartext-pluggable-authentication::.)
This option was added in MySQL 5.7.10.
'--get-server-public-key'
Command-Line Format
'--get-server-public-key'
Introduced
5.7.23
Type
Boolean
Request from the server the RSA public key that it uses for key pair-based password exchange. This option applies to clients that connect to the server using an account that authenticates with the 'caching_sha2_password' authentication plugin. For connections by such accounts, the server does not send the public key to the client unless requested. The option is ignored for accounts that do not authenticate with that plugin. It is also ignored if RSA-based password exchange is not needed, 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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host=host_name'
Type
String
Default Value
'localhost'
Connect to the MySQL server on the given host.
'--keys', '-k'
Command-Line Format
'--keys'
Show table indexes.
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysqlshow': mysqlshow. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysqlshow': mysqlshow. should not prompt for one, use the '--skip-password' option.
'--pipe', '-W'
Command-Line Format
'--pipe'
Type
String
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the 'named_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 the 'named_pipe_full_access_group' system variable.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysqlshow': mysqlshow. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
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, see *note option-file-options::.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note transport-protocols::.
'--secure-auth'
Command-Line Format
'--secure-auth'
Deprecated
Yes
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, see *note account-upgrades::.
'--server-public-key-path=FILE_NAME'
Command-Line Format
'--server-public-key-path=file_name'
Introduced
5.7.23
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
The '--server-public-key-path' option was added in MySQL 5.7.23.
'--shared-memory-base-name=NAME'
Command-Line Format
'--shared-memory-base-name=name'
Platform Specific
Windows
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 'MYSQL'. The shared-memory name is case-sensitive.
This option applies only if the server was started with the 'shared_memory' system variable enabled to support shared-memory connections.
'--show-table-type', '-t'
Command-Line Format
'--show-table-type'
Show a column indicating the table type, as in *note 'SHOW FULL TABLES': show-tables. The type is 'BASE TABLE' or 'VIEW'.
'--socket=PATH', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_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. See *note encrypted-connection-options::.
'--status', '-i'
Command-Line Format
'--status'
Display extra information about each table.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-ciphers::.
This option was added in MySQL 5.7.10.
'--user=USER_NAME', '-u USER_NAME'
Command-Line Format
'--user=user_name,'
Type
String
The user name of the MySQL account to use for connecting to the server.
'--verbose', '-v'
Command-Line Format
'--verbose'
Verbose mode. Print more information about what the program does. This option can be used multiple times to increase the amount of information.
'--version', '-V'
Command-Line Format
'--version'
Display version information and exit.
File: manual.info.tmp, Node: mysqlslap, Prev: mysqlshow, Up: programs-client
*note 'mysqlslap': mysqlslap. is a diagnostic program designed to emulate client load for a MySQL server and to report the timing of each stage. It works as if multiple clients are accessing the server.
Invoke *note 'mysqlslap': mysqlslap. like this:
mysqlslap [OPTIONS]
Some options such as '--create' or '--query' enable you to specify a string containing an SQL statement or a file containing statements. If you specify a file, by default it must contain one statement per line. (That is, the implicit statement delimiter is the newline character.) Use the '--delimiter' option to specify a different delimiter, which enables you to specify statements that span multiple lines or place multiple statements on a single line. You cannot include comments in a file; *note 'mysqlslap': mysqlslap. does not understand them.
*note 'mysqlslap': mysqlslap. runs in three stages:
Create schema, table, and optionally any stored programs or data to use for the test. This stage uses a single client connection.
Run the load test. This stage can use many client connections.
Clean up (disconnect, drop table if specified). This stage uses a single client connection.
Examples:
Supply your own create and query SQL statements, with 50 clients querying and 200 selects for each (enter the command on a single line):
mysqlslap --delimiter=";"
--create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)"
--query="SELECT * FROM a" --concurrency=50 --iterations=200
Let note 'mysqlslap': mysqlslap. build the query SQL statement with a table of two note 'INT': integer-types. columns and three *note 'VARCHAR': char. columns. Use five clients querying 20 times each. Do not create the table or insert the data (that is, use the previous test's schema and data):
mysqlslap --concurrency=5 --iterations=20
--number-int-cols=2 --number-char-cols=3
--auto-generate-sql
Tell the program to load the create, insert, and query SQL statements from the specified files, where the 'create.sql' file has multiple table creation statements delimited by '';'' and multiple insert statements delimited by '';''. The '--query' file has multiple queries delimited by '';''. Run all the load statements, then run all the queries in the query file with five clients (five times each):
mysqlslap --concurrency=5
--iterations=5 --query=query.sql --create=create.sql
--delimiter=";"
note 'mysqlslap': mysqlslap. supports the following options, which can be specified on the command line or in the '[mysqlslap]' and '[client]' groups of an option file. For information about option files used by MySQL programs, see note option-files::.
mysqlslap Options
Option Name Description IntroducedDeprecated
-auto-generate-sql
Generate SQL statements automatically when they are not supplied in files or using command options
-auto-generate-sql-add-autoincrement
Add AUTO_INCREMENT column to automatically generated tables
-auto-generate-sql-execute-number
Specify how many queries to generate automatically
-auto-generate-sql-guid-primary
Add a GUID-based primary key to automatically generated tables
-auto-generate-sql-load-type
Specify the test load type
-auto-generate-sql-secondary-indexes
Specify how many secondary indexes to add to automatically generated tables
-auto-generate-sql-unique-query-number
How many different queries to generate for automatic tests
-auto-generate-sql-unique-write-number
How many different queries to generate for -auto-generate-sql-write-number
-auto-generate-sql-write-number
How many row inserts to perform on each thread
-commit
How many statements to execute before committing
-compress
Compress all information sent between client and server
-concurrency
Number of clients to simulate when issuing the SELECT statement
-create
File or string containing the statement to use for creating the table
-create-schema
Schema in which to run the tests
-csv
Generate output in comma-separated values format
-debug
Write debugging log
-debug-check
Print debugging information when program exits
-debug-info
Print debugging information, memory, and CPU statistics when program exits
-default-auth
Authentication plugin to use
-defaults-extra-file
Read named option file in addition to usual option files
-defaults-file
Read only named option file
-defaults-group-suffix
Option group suffix value
-delimiter
Delimiter to use in SQL statements
-detach
Detach (close and reopen) each connection after each N statements
-enable-cleartext-plugin
Enable cleartext authentication plugin
-engine
Storage engine to use for creating the table
-get-server-public-key
Request RSA 5.7.23 public key from
server
-help
Display help message and exit
-host
Host on which MySQL server is located
-iterations
Number of times to run the tests
-login-path
Read login path options from .mylogin.cnf
-no-defaults
Read no option files
-no-drop
Do not drop any schema created during the test run
-number-char-cols
Number of VARCHAR columns to use if -auto-generate-sql is specified
-number-int-cols
Number of INT columns to use if -auto-generate-sql is specified
-number-of-queries
Limit each client to approximately this number of queries
-only-print
Do not connect to databases. mysqlslap only prints what it would have done
-password
Password to use when connecting to server
-pipe
Connect to server using named pipe (Windows only)
-plugin-dir
Directory where plugins are installed
-port
TCP/IP port number for connection
-post-query
File or string containing the statement to execute after the tests have completed
-post-system
String to execute using system() after the tests have completed
-pre-query
File or string containing the statement to execute before running the tests
-pre-system
String to execute using system() before running the tests
-print-defaults
Print default options
-protocol
Transport protocol to use
-query
File or string containing the SELECT statement to use for retrieving data
-secure-auth
Do not send Yes passwords to
server in old (pre-4.1) format
-server-public-key-path
Path name to file 5.7.23 containing RSA
public key
-shared-memory-base-name
Shared-memory name for shared-memory connections (Windows only)
-silent
Silent mode
-socket
Unix socket file or Windows named pipe to use
-sql-mode
Set SQL mode for client session
-ssl
Enable connection encryption
-ssl-ca
File that contains list of trusted SSL Certificate Authorities
-ssl-capath
Directory that contains trusted SSL Certificate Authority certificate files
-ssl-cert
File that contains X.509 certificate
-ssl-cipher
Permissible ciphers for connection encryption
-ssl-crl
File that contains certificate revocation lists
-ssl-crlpath
Directory that contains certificate revocation-list files
-ssl-key
File that contains X.509 key
-ssl-mode
Desired security 5.7.11 state of
connection to server
-ssl-verify-server-cert
Verify host name against server certificate Common Name identity
-tls-version
Permissible TLS 5.7.10 protocols for
encrypted connections
-user
MySQL user name to use when connecting to server
-verbose
Verbose mode
-version
Display version information and exit
'--help', '-?'
Command-Line Format
'--help'
Display a help message and exit.
'--auto-generate-sql', '-a'
Command-Line Format
'--auto-generate-sql'
Type
Boolean
Default Value
'FALSE'
Generate SQL statements automatically when they are not supplied in files or using command options.
'--auto-generate-sql-add-autoincrement'
Command-Line Format
'--auto-generate-sql-add-autoincrement'
Type
Boolean
Default Value
'FALSE'
Add an 'AUTO_INCREMENT' column to automatically generated tables.
'--auto-generate-sql-execute-number=N'
Command-Line Format
'--auto-generate-sql-execute-number=#'
Type
Numeric
Specify how many queries to generate automatically.
'--auto-generate-sql-guid-primary'
Command-Line Format
'--auto-generate-sql-guid-primary'
Type
Boolean
Default Value
'FALSE'
Add a GUID-based primary key to automatically generated tables.
'--auto-generate-sql-load-type=TYPE'
Command-Line Format
'--auto-generate-sql-load-type=type'
Type
Enumeration
Default Value
'mixed'
Valid Values
'read' 'write' 'key' 'update' 'mixed'
Specify the test load type. The permissible values are 'read' (scan tables), 'write' (insert into tables), 'key' (read primary keys), 'update' (update primary keys), or 'mixed' (half inserts, half scanning selects). The default is 'mixed'.
'--auto-generate-sql-secondary-indexes=N'
Command-Line Format
'--auto-generate-sql-secondary-indexes=#'
Type
Numeric
Default Value
'0'
Specify how many secondary indexes to add to automatically generated tables. By default, none are added.
'--auto-generate-sql-unique-query-number=N'
Command-Line Format
'--auto-generate-sql-unique-query-number=#'
Type
Numeric
Default Value
'10'
How many different queries to generate for automatic tests. For example, if you run a 'key' test that performs 1000 selects, you can use this option with a value of 1000 to run 1000 unique queries, or with a value of 50 to perform 50 different selects. The default is 10.
'--auto-generate-sql-unique-write-number=N'
Command-Line Format
'--auto-generate-sql-unique-write-number=#'
Type
Numeric
Default Value
'10'
How many different queries to generate for '--auto-generate-sql-write-number'. The default is 10.
'--auto-generate-sql-write-number=N'
Command-Line Format
'--auto-generate-sql-write-number=#'
Type
Numeric
Default Value
'100'
How many row inserts to perform. The default is 100.
'--commit=N'
Command-Line Format
'--commit=#'
Type
Numeric
Default Value
'0'
How many statements to execute before committing. The default is 0 (no commits are done).
'--compress', '-C'
Command-Line Format
'--compress[={OFF|ON}]'
Type
Boolean
Default Value
'OFF'
Compress all information sent between the client and the server if possible. See *note connection-compression-control::.
'--concurrency=N', '-c N'
Command-Line Format
'--concurrency=#'
Type
Numeric
The number of parallel clients to simulate.
'--create=VALUE'
Command-Line Format
'--create=value'
Type
String
The file or string containing the statement to use for creating the table.
'--create-schema=VALUE'
Command-Line Format
'--create-schema=value'
Type
String
The schema in which to run the tests.
Note:
If the '--auto-generate-sql' option is also given, *note 'mysqlslap': mysqlslap. drops the schema at the end of the test run. To avoid this, use the '--no-drop' option as well.
'--csv[=FILE_NAME]'
Command-Line Format
'--csv=[file]'
Type
File name
Generate output in comma-separated values format. The output goes to the named file, or to the standard output if no file is given.
'--debug[=DEBUG_OPTIONS]', '-# [DEBUG_OPTIONS]'
Command-Line Format
'--debug[=debug_options]'
Type
String
Default Value
'd:t:o,/tmp/mysqlslap.trace'
Write a debugging log. A typical DEBUG_OPTIONS string is 'd:t:o,FILE_NAME'. The default is 'd:t:o,/tmp/mysqlslap.trace'.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-check'
Command-Line Format
'--debug-check'
Type
Boolean
Default Value
'FALSE'
Print some debugging information when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--debug-info', '-T'
Command-Line Format
'--debug-info'
Type
Boolean
Default Value
'FALSE'
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using 'WITH_DEBUG'. MySQL release binaries provided by Oracle are not built using this option.
'--default-auth=PLUGIN'
Command-Line Format
'--default-auth=plugin'
Type
String
A hint about which client-side authentication plugin to use. See *note pluggable-authentication::.
'--defaults-extra-file=FILE_NAME'
Command-Line Format
'--defaults-extra-file=file_name'
Type
File 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. If FILE_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, see *note option-file-options::.
'--defaults-file=FILE_NAME'
Command-Line Format
'--defaults-file=file_name'
Type
File name
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If FILE_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, see *note option-file-options::.
'--defaults-group-suffix=STR'
Command-Line Format
'--defaults-group-suffix=str'
Type
String
Read not only the usual option groups, but also groups with the usual names and a suffix of STR. For example, *note 'mysqlslap': mysqlslap. normally reads the '[client]' and '[mysqlslap]' groups. If this option is given as '--defaults-group-suffix=_other', *note 'mysqlslap': mysqlslap. also reads the '[client_other]' and '[mysqlslap_other]' groups.
For additional information about this and other option-file options, see *note option-file-options::.
'--delimiter=STR', '-F STR'
Command-Line Format
'--delimiter=str'
Type
String
The delimiter to use in SQL statements supplied in files or using command options.
'--detach=N'
Command-Line Format
'--detach=#'
Type
Numeric
Default Value
'0'
Detach (close and reopen) each connection after each N statements. The default is 0 (connections are not detached).
'--enable-cleartext-plugin'
Command-Line Format
'--enable-cleartext-plugin'
Type
Boolean
Default Value
'FALSE'
Enable the 'mysql_clear_password' cleartext authentication plugin. (See *note cleartext-pluggable-authentication::.)
'--engine=ENGINE_NAME', '-e ENGINE_NAME'
Command-Line Format
'--engine=engine_name'
Type
String
The storage engine to use for creating tables.
'--get-server-public-key'
Command-Line Format
'--get-server-public-key'
Introduced
5.7.23
Type
Boolean
Request from the server the RSA public key that it uses for key pair-based password exchange. This option applies to clients that connect to the server using an account that authenticates with the 'caching_sha2_password' authentication plugin. For connections by such accounts, the server does not send the public key to the client unless requested. The option is ignored for accounts that do not authenticate with that plugin. It is also ignored if RSA-based password exchange is not needed, 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 the 'caching_sha2_password' plugin, see *note caching-sha2-pluggable-authentication::.
The '--get-server-public-key' option was added in MySQL 5.7.23.
'--host=HOST_NAME', '-h HOST_NAME'
Command-Line Format
'--host=host_name'
Type
String
Default Value
'localhost'
Connect to the MySQL server on the given host.
'--iterations=N', '-i N'
Command-Line Format
'--iterations=#'
Type
Numeric
The number of times to run the tests.
'--login-path=NAME'
Command-Line Format
'--login-path=name'
Type
String
Read options from the named login path in the '.mylogin.cnf' login path file. A 'login 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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--no-drop'
Command-Line Format
'--no-drop'
Type
Boolean
Default Value
'FALSE'
Prevent *note 'mysqlslap': mysqlslap. from dropping any schema it creates during the test run.
'--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 the note 'mysql_config_editor': mysql-config-editor. utility. See note mysql-config-editor::.
For additional information about this and other option-file options, see *note option-file-options::.
'--number-char-cols=N', '-x N'
Command-Line Format
'--number-char-cols=#'
Type
Numeric
The number of *note 'VARCHAR': char. columns to use if '--auto-generate-sql' is specified.
'--number-int-cols=N', '-y N'
Command-Line Format
'--number-int-cols=#'
Type
Numeric
The number of *note 'INT': integer-types. columns to use if '--auto-generate-sql' is specified.
'--number-of-queries=N'
Command-Line Format
'--number-of-queries=#'
Type
Numeric
Limit each client to approximately this many queries. Query counting takes into account the statement delimiter. For example, if you invoke *note 'mysqlslap': mysqlslap. as follows, the ';' delimiter is recognized so that each instance of the query string counts as two queries. As a result, 5 rows (not 10) are inserted.
mysqlslap --delimiter=";" --number-of-queries=10
--query="use test;insert into t values(null)"
'--only-print'
Command-Line Format
'--only-print'
Type
Boolean
Default Value
'FALSE'
Do not connect to databases. *note 'mysqlslap': mysqlslap. only prints what it would have done.
'--password[=PASSWORD]', '-p[PASSWORD]'
Command-Line Format
'--password[=password]'
Type
String
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, *note 'mysqlslap': mysqlslap. prompts for one. If given, there must be no 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. See *note password-security-user::.
To explicitly specify that there is no password and that *note 'mysqlslap': mysqlslap. should not prompt for one, use the '--skip-password' option.
'--pipe', '-W'
Command-Line Format
'--pipe'
Type
String
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the 'named_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 the 'named_pipe_full_access_group' system variable.
'--plugin-dir=DIR_NAME'
Command-Line Format
'--plugin-dir=dir_name'
Type
Directory name
The directory in which to look for plugins. Specify this option if the '--default-auth' option is used to specify an authentication plugin but note 'mysqlslap': mysqlslap. does not find it. See note pluggable-authentication::.
'--port=PORT_NUM', '-P PORT_NUM'
Command-Line Format
'--port=port_num'
Type
Numeric
Default Value
'3306'
For TCP/IP connections, the port number to use.
'--post-query=VALUE'
Command-Line Format
'--post-query=value'
Type
String
The file or string containing the statement to execute after the tests have completed. This execution is not counted for timing purposes.
'--post-system=STR'
Command-Line Format
'--post-system=str'
Type
String
The string to execute using 'system()' after the tests have completed. This execution is not counted for timing purposes.
'--pre-query=VALUE'
Command-Line Format
'--pre-query=value'
Type
String
The file or string containing the statement to execute before running the tests. This execution is not counted for timing purposes.
'--pre-system=STR'
Command-Line Format
'--pre-system=str'
Type
String
The string to execute using 'system()' before running the tests. This execution is not counted for timing purposes.
'--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, see *note option-file-options::.
'--protocol={TCP|SOCKET|PIPE|MEMORY}'
Command-Line Format
'--protocol=type'
Type
String
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, see *note transport-protocols::.
'--query=VALUE', '-q VALUE'
Command-Line Format
'--query=value'
Type
String
The file or string containing the *note 'SELECT': select. statement to use for retrieving data.
'--secure-auth'
Command-Line Format
'--secure-auth'
Deprecated
Yes
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, see *note account-upgrades::.
'--server-public-key-path=FILE_NAME'
Command-Line Format
'--server-public-key-path=file_name'
Introduced
5.7.23
Type
File 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 the 'sha256_password' or 'caching_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'.
For 'sha256_password', this option applies only if MySQL was built using OpenSSL.
For information about the 'sha256_password' and 'caching_sha2_password' plugins, see note sha256-pluggable-authentication::, and note caching-sha2-pluggable-authentication::.
The '--server-public-key-path' option was added in MySQL 5.7.23.
'--shared-memory-base-name=NAME'
Command-Line Format
'--shared-memory-base-name=name'
Platform Specific
Windows
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is 'MYSQL'. The shared-memory name is case-sensitive.
This option applies only if the server was started with the 'shared_memory' system variable enabled to support shared-memory connections.
'--silent', '-s'
Command-Line Format
'--silent'
Silent mode. No output.
'--socket=PATH', '-S PATH'
Command-Line Format
'--socket={file_name|pipe_name}'
Type
String
For connections to 'localhost', 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 the 'named_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 the 'named_pipe_full_access_group' system variable.
'--sql-mode=MODE'
Command-Line Format
'--sql-mode=mode'
Type
String
Set the SQL mode for the client session.
'--ssl*'
Options that begin with '--ssl' specify whether to connect to the server using encryption and indicate where to find SSL keys and certificates. See *note encrypted-connection-options::.
'--tls-version=PROTOCOL_LIST'
Command-Line Format
'--tls-version=protocol_list'
Introduced
5.7.10
Type
String
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, see *note encrypted-connection-protocols-ciphers::.
This option was added in MySQL 5.7.10.
'--user=USER_NAME', '-u USER_NAME'
Command-Line Format
'--user=user_name,'
Type
String
The user name of the MySQL account to use for connecting to the server.
'--verbose', '-v'
Command-Line Format
'--verbose'
Verbose mode. Print more information about what the program does. This option can be used multiple times to increase the amount of information.
'--version', '-V'
Command-Line Format
'--version'
Display version information and exit.
File: manual.info.tmp, Node: programs-admin-utils, Next: programs-development, Prev: programs-client, Up: programs