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

MySQL 5.7 Reference Manual  / ...  / MySQL Programs  / Client Programs  /  mysqlpump — A Database Backup Program

4.5.6 mysqlpump — A Database Backup Program

Themysqlpump client utility performslogical 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.

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 (CREATE USER,GRANT) rather than as inserts into themysql system database

  • Capability of creating compressed output

  • Progress indicator (the values are estimates)

  • For dump file reloading, faster secondary index creation forInnoDB tables by adding indexes after rows are inserted

mysqlpump requires at least theSELECT privilege for dumped tables,SHOW VIEW for dumped views,TRIGGER for dumped triggers, andLOCK TABLES if the--single-transaction option is not used. TheSELECT privilege on themysql 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 appropriateCREATE 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 (seeSection 10.4, “Connection Character Sets and Collations”), 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,mysqlpump dumps all databases (with certain exceptions noted inmysqlpump 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:

mysqlpumpdb_namemysqlpumpdb_name tbl_name1 tbl_name2 ...

To treat all name arguments as database names, use the--databases option:

mysqlpump --databasesdb_name1 db_name2 ...

By default,mysqlpump does not dump user account definitions, even if you dump themysql system database that contains the grant tables. To dump grant table contents as logical definitions in the form ofCREATE USER andGRANT 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.

mysqlpump supports several options for including or excluding databases, tables, stored programs, and user definitions. Seemysqlpump Object Selection.

To reload a dump file, execute the statements that it contains. For example, use themysql client:

mysqlpump [options] > dump.sqlmysql < dump.sql

The following discussion provides additionalmysqlpump usage examples.

To see a list of the optionsmysqlpump supports, issue the commandmysqlpump --help.

mysqlpump Option Summary

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,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, seeSection 4.2.2.2, “Using Option Files”.

Table 4.18 mysqlpump Options

Option NameDescriptionIntroduced
--add-drop-databaseAdd DROP DATABASE statement before each CREATE DATABASE statement
--add-drop-tableAdd DROP TABLE statement before each CREATE TABLE statement
--add-drop-userAdd DROP USER statement before each CREATE USER statement
--add-locksSurround each table dump with LOCK TABLES and UNLOCK TABLES statements
--all-databasesDump all databases
--bind-addressUse specified network interface to connect to MySQL Server
--character-sets-dirDirectory where character sets are installed
--complete-insertUse complete INSERT statements that include column names
--compressCompress all information sent between client and server
--compress-outputOutput compression algorithm
--databasesInterpret all name arguments as database names
--debugWrite debugging log
--debug-checkPrint debugging information when program exits
--debug-infoPrint debugging information, memory, and CPU statistics when program exits
--default-authAuthentication plugin to use
--default-character-setSpecify default character set
--default-parallelismDefault number of threads for parallel processing
--defaults-extra-fileRead named option file in addition to usual option files
--defaults-fileRead only named option file
--defaults-group-suffixOption group suffix value
--defer-table-indexesFor reloading, defer index creation until after loading table rows
--eventsDump events from dumped databases
--exclude-databasesDatabases to exclude from dump
--exclude-eventsEvents to exclude from dump
--exclude-routinesRoutines to exclude from dump
--exclude-tablesTables to exclude from dump
--exclude-triggersTriggers to exclude from dump
--exclude-usersUsers to exclude from dump
--extended-insertUse multiple-row INSERT syntax
--get-server-public-keyRequest RSA public key from server5.7.23
--helpDisplay help message and exit
--hex-blobDump binary columns using hexadecimal notation
--hostHost on which MySQL server is located
--include-databasesDatabases to include in dump
--include-eventsEvents to include in dump
--include-routinesRoutines to include in dump
--include-tablesTables to include in dump
--include-triggersTriggers to include in dump
--include-usersUsers to include in dump
--insert-ignoreWrite INSERT IGNORE rather than INSERT statements
--log-error-fileAppend warnings and errors to named file
--login-pathRead login path options from .mylogin.cnf
--max-allowed-packetMaximum packet length to send to or receive from server
--net-buffer-lengthBuffer size for TCP/IP and socket communication
--no-create-dbDo not write CREATE DATABASE statements
--no-create-infoDo not write CREATE TABLE statements that re-create each dumped table
--no-defaultsRead no option files
--parallel-schemasSpecify schema-processing parallelism
--passwordPassword to use when connecting to server
--plugin-dirDirectory where plugins are installed
--portTCP/IP port number for connection
--print-defaultsPrint default options
--protocolTransport protocol to use
--replaceWrite REPLACE statements rather than INSERT statements
--result-fileDirect output to a given file
--routinesDump stored routines (procedures and functions) from dumped databases
--secure-authDo not send passwords to server in old (pre-4.1) format
--server-public-key-pathPath name to file containing RSA public key5.7.23
--set-charsetAdd SET NAMES default_character_set to output
--set-gtid-purgedWhether to add SET @@GLOBAL.GTID_PURGED to output5.7.18
--single-transactionDump tables within single transaction
--skip-definerOmit DEFINER and SQL SECURITY clauses from view and stored program CREATE statements
--skip-dump-rowsDo not dump table rows
--socketUnix socket file or Windows named pipe to use
--sslEnable connection encryption
--ssl-caFile that contains list of trusted SSL Certificate Authorities
--ssl-capathDirectory that contains trusted SSL Certificate Authority certificate files
--ssl-certFile that contains X.509 certificate
--ssl-cipherPermissible ciphers for connection encryption
--ssl-crlFile that contains certificate revocation lists
--ssl-crlpathDirectory that contains certificate revocation-list files
--ssl-keyFile that contains X.509 key
--ssl-modeDesired security state of connection to server5.7.11
--ssl-verify-server-certVerify host name against server certificate Common Name identity
--tls-versionPermissible TLS protocols for encrypted connections5.7.10
--triggersDump triggers for each dumped table
--tz-utcAdd SET TIME_ZONE='+00:00' to dump file
--userMySQL user name to use when connecting to server
--usersDump user accounts
--versionDisplay version information and exit
--watch-progressDisplay 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 aDROP DATABASE statement before eachCREATE DATABASE statement.

  • --add-drop-table

    Command-Line Format--add-drop-table

    Write aDROP TABLE statement before eachCREATE TABLE statement.

  • --add-drop-user

    Command-Line Format--add-drop-user

    Write aDROP USER statement before eachCREATE USER statement.

  • --add-locks

    Command-Line Format--add-locks

    Surround each table dump withLOCK TABLES andUNLOCK TABLES statements. This results in faster inserts when the dump file is reloaded. SeeSection 8.2.4.1, “Optimizing INSERT Statements”.

    This option does not work with parallelism becauseINSERT statements from different tables can be interleaved andUNLOCK 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 inmysqlpump 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
    TypeDirectory name

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

  • --complete-insert

    Command-Line Format--complete-insert

    Write completeINSERT statements that include column names.

  • --compress,-C

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

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

  • --compress-output=algorithm

    Command-Line Format--compress-output=algorithm
    TypeEnumeration
    Valid Values

    LZ4

    ZLIB

    By default,mysqlpump does not compress output. This option specifies output compression using the specified algorithm. Permitted algorithms areLZ4 andZLIB.

    To uncompress compressed output, you must have an appropriate utility. If the system commandslz4 andopenssl zlib are not available, as of MySQL 5.7.10, MySQL distributions includelz4_decompress andzlib_decompress utilities that can be used to decompressmysqlpump output that was compressed using the--compress-output=LZ4 and--compress-output=ZLIB options. For more information, seeSection 4.8.1, “lz4_decompress — Decompress mysqlpump LZ4-Compressed Output”, andSection 4.8.5, “zlib_decompress — Decompress mysqlpump ZLIB-Compressed Output”.

    Alternatives include thelz4 andopenssl commands, if they are installed on your system. For example,lz4 can uncompressLZ4 output:

    lz4 -dinput_file output_file

    ZLIB output can be uncompresed like this:

    openssl zlib -d <input_file >output_file
  • --databases,-B

    Command-Line Format--databases

    Normally,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.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]
    TypeString
    Default Valued:t:O,/tmp/mysqlpump.trace

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

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

  • --debug-check

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

    Print some debugging information when the program exits.

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

  • --debug-info,-T

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

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

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

  • --default-auth=plugin

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

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

  • --default-character-set=charset_name

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

    Usecharset_name as the default character set. SeeSection 10.15, “Character Set Configuration”. If no character set is specified,mysqlpump usesutf8.

  • --default-parallelism=N

    Command-Line Format--default-parallelism=N
    TypeInteger
    Default Value2

    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, seemysqlpump Parallel Processing.

    With--default-parallelism=0 and no--parallel-schemas options,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
    TypeFile name

    Read this option file after the global option file but (on Unix) before the user option file. If the file does not exist or is otherwise inaccessible, an error occurs. Iffile_name is not an absolute path name, it is interpreted relative to the current directory.

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

  • --defaults-file=file_name

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

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

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

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

  • --defaults-group-suffix=str

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

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

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

  • --defer-table-indexes

    Command-Line Format--defer-table-indexes
    TypeBoolean
    Default ValueTRUE

    In the dump output, defer index creation for each table until after its rows have been loaded. This works for all storage engines, but forInnoDB applies only for secondary indexes.

    This option is enabled by default; use--skip-defer-table-indexes to disable it.

  • --events

    Command-Line Format--events
    TypeBoolean
    Default ValueTRUE

    Include Event Scheduler events for the dumped databases in the output. Event dumping requires theEVENT privileges for those databases.

    The output generated by using--events containsCREATE 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 themysql.event table directly, using a MySQL account that has appropriate privileges for themysql database.

    This option is enabled by default; use--skip-events to disable it.

  • --exclude-databases=db_list

    Command-Line Format--exclude-databases=db_list
    TypeString

    Do not dump the databases indb_list, which is a list of one or more comma-separated database names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --exclude-events=event_list

    Command-Line Format--exclude-events=event_list
    TypeString

    Do not dump the databases inevent_list, which is a list of one or more comma-separated event names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --exclude-routines=routine_list

    Command-Line Format--exclude-routines=routine_list
    TypeString

    Do not dump the events inroutine_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, seemysqlpump Object Selection.

  • --exclude-tables=table_list

    Command-Line Format--exclude-tables=table_list
    TypeString

    Do not dump the tables intable_list, which is a list of one or more comma-separated table names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --exclude-triggers=trigger_list

    Command-Line Format--exclude-triggers=trigger_list
    TypeString

    Do not dump the triggers intrigger_list, which is a list of one or more comma-separated trigger names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --exclude-users=user_list

    Command-Line Format--exclude-users=user_list
    TypeString

    Do not dump the user accounts inuser_list, which is a list of one or more comma-separated account names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --extended-insert=N

    Command-Line Format--extended-insert=N

    WriteINSERT statements using multiple-row syntax that includes severalVALUES 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 eachINSERT statement. The default is 250. A value of 1 produces oneINSERT statement per table row.

  • --get-server-public-key

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

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

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

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

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

  • --hex-blob

    Command-Line Format--hex-blob

    Dump binary columns using hexadecimal notation (for example,'abc' becomes0x616263). The affected data types areBINARY,VARBINARY,BLOB types,BIT, all spatial data types, and other non-binary data types when used with thebinary character set.

  • --host=host_name,-hhost_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
    TypeString

    Dump the databases indb_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, seemysqlpump Object Selection.

  • --include-events=event_list

    Command-Line Format--include-events=event_list
    TypeString

    Dump the events inevent_list, which is a list of one or more comma-separated event names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --include-routines=routine_list

    Command-Line Format--include-routines=routine_list
    TypeString

    Dump the routines inroutine_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, seemysqlpump Object Selection.

  • --include-tables=table_list

    Command-Line Format--include-tables=table_list
    TypeString

    Dump the tables intable_list, which is a list of one or more comma-separated table names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --include-triggers=trigger_list

    Command-Line Format--include-triggers=trigger_list
    TypeString

    Dump the triggers intrigger_list, which is a list of one or more comma-separated trigger names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --include-users=user_list

    Command-Line Format--include-users=user_list
    TypeString

    Dump the user accounts inuser_list, which is a list of one or more comma-separated user names. Multiple instances of this option are additive. For more information, seemysqlpump Object Selection.

  • --insert-ignore

    Command-Line Format--insert-ignore

    WriteINSERT IGNORE statements rather thanINSERT statements.

  • --log-error-file=file_name

    Command-Line Format--log-error-file=file_name
    TypeFile name

    Log warnings and errors by appending them to the named file. If this option is not given,mysqlpump writes warnings and errors to the standard error output.

  • --login-path=name

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

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

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

  • --max-allowed-packet=N

    Command-Line Format--max-allowed-packet=N
    TypeNumeric
    Default Value25165824

    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
    TypeNumeric
    Default Value1047552

    The initial size of the buffer for client/server communication. When creating multiple-rowINSERT statements (as with the--extended-insert option),mysqlpump creates rows up toN bytes long. If you use this option to increase the value, ensure that the MySQL servernet_buffer_length system variable has a value at least this large.

  • --no-create-db

    Command-Line Format--no-create-db

    Suppress anyCREATE DATABASE statements that might otherwise be included in the output.

  • --no-create-info,-t

    Command-Line Format--no-create-info

    Do not writeCREATE 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 themysql_config_editor utility. SeeSection 4.6.6, “mysql_config_editor — MySQL Configuration Utility”.

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

  • --parallel-schemas=[N:]db_list

    Command-Line Format--parallel-schemas=[N:]schema_list
    TypeString

    Create a queue for processing the databases indb_list, which is a list of one or more comma-separated database names. IfN is given, the queue usesN threads. IfN is not given, the--default-parallelism option determines the number of queue threads.

    Multiple instances of this option create multiple queues.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, seemysqlpump Parallel Processing.

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

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

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

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

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

  • --plugin-dir=dir_name

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

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

  • --port=port_num,-Pport_num

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

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

  • --print-defaults

    Command-Line Format--print-defaults

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

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

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

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

    TCP

    SOCKET

    PIPE

    MEMORY

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

  • --replace

    Command-Line Format--replace

    WriteREPLACE statements rather thanINSERT statements.

  • --result-file=file_name

    Command-Line Format--result-file=file_name
    TypeFile 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\n characters from being converted to\r\n carriage return/newline sequences.

  • --routines

    Command-Line Format--routines
    TypeBoolean
    Default ValueTRUE

    Include stored routines (procedures and functions) for the dumped databases in the output. This option requires theSELECT privilege for themysql.proc table.

    The output generated by using--routines containsCREATE PROCEDURE andCREATE 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 themysql.proc table directly, using a MySQL account that has appropriate privileges for themysql 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
    Introduced5.7.23
    TypeFile name

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

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

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

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

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

  • --set-charset

    Command-Line Format--set-charset

    WriteSET NAMESdefault_character_set to the output.

    This option is enabled by default. To disable it and suppress theSET NAMES statement, use--skip-set-charset.

  • --set-gtid-purged=value

    Command-Line Format--set-gtid-purged=value
    Introduced5.7.18
    TypeEnumeration
    Default ValueAUTO
    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 aSET @@GLOBAL.gtid_purged 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 isAUTO.

    ValueMeaning
    OFFAdd noSET statement to the output.
    ONAdd aSET statement to the output. An error occurs if GTIDs are not enabled on the server.
    AUTOAdd aSET 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, ifAUTO evaluates toON).

    This option was added in MySQL 5.7.18.

  • --single-transaction

    Command-Line Format--single-transaction

    This option sets the transaction isolation mode toREPEATABLE READ and sends aSTART TRANSACTION SQL statement to the server before dumping data. It is useful only with transactional tables such asInnoDB, because then it dumps the consistent state of the database at the time whenSTART TRANSACTION was issued without blocking any applications.

    When using this option, you should keep in mind that onlyInnoDB tables are dumped in a consistent state. For example, anyMyISAM orMEMORY 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:ALTER TABLE,CREATE TABLE,DROP TABLE,RENAME TABLE,TRUNCATE TABLE. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause theSELECT that is performed bymysqlpump 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
    TypeBoolean
    Default ValueFALSE

    OmitDEFINER andSQL SECURITY clauses from theCREATE statements for views and stored programs. The dump file, when reloaded, creates objects that use the defaultDEFINER andSQL SECURITY values. SeeSection 23.6, “Stored Object Access Control”.

  • --skip-dump-rows,-d

    Command-Line Format--skip-dump-rows
    TypeBoolean
    Default ValueFALSE

    Do not dump table rows.

  • --socket=path,-Spath

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

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

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

  • --ssl*

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

  • --tls-version=protocol_list

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

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

    TLSv1,TLSv1.1 (yaSSL)

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

    This option was added in MySQL 5.7.10.

  • --triggers

    Command-Line Format--triggers
    TypeBoolean
    Default ValueTRUE

    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 enablesTIMESTAMP columns to be dumped and reloaded between servers in different time zones.mysqlpump sets its connection time zone to UTC and addsSET TIME_ZONE='+00:00' to the dump file. Without this option,TIMESTAMP 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,-uuser_name

    Command-Line Format--user=user_name
    TypeString

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

  • --users

    Command-Line Format--users
    TypeBoolean
    Default ValueFALSE

    Dump user accounts as logical definitions in the form ofCREATE USER andGRANT statements.

    User definitions are stored in the grant tables in themysql system database. By default,mysqlpump does not include the grant tables inmysql 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
    TypeBoolean
    Default ValueTRUE

    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

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:

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 witht and all five-character table names that end withtmp.

For users, a name specified without a host part is interpreted with an implied host of%. For example,u1 andu1@% are equivalent. This is the same equivalence that applies in MySQL generally (seeSection 6.2.4, “Specifying Account Names”).

Inclusion and exclusion options interact as follows:

  • By default, with no inclusion or exclusion options,mysqlpump dumps all databases (with certain exceptions noted inmysqlpump 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 databasesdb1 anddb2, but excludes tablesdb1.t1 anddb2.t2:

mysqlpump --include-databases=db1,db2 --exclude-tables=db1.t1,db2.t2

The following options provide alternative ways to specify which databases to dump:

mysqlpump Parallel Processing

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,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 indb_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 withN:, the queue usesN 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 (seemysqlpump Object Selection).

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,mysqlpump uses parallelism between the sets of databases processed by the queues, to dump multiple databases simultaneously. For a queue that uses multiple threads,mysqlpump uses parallelism within databases, to dump multiple objects from a given database simultaneously. Exceptions can occur; for example,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,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 byUSE 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

mysqlpump sets up a queue to processdb1 anddb2, another queue to processdb3, 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 fordb1 anddb2 uses five threads, the queue fordb3 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,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

mysqlpump does not dump theINFORMATION_SCHEMA,performance_schema,ndbinfo, orsys 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.

mysqlpump does not dumpInnoDBCREATE TABLESPACE statements.

mysqlpump dumps user accounts in logical form usingCREATE USER andGRANT statements (for example, when you use the--include-users or--users option). For this reason, dumps of themysql system database do not by default include the grant tables that contain user definitions:user,db,tables_priv,columns_priv,procs_priv, orproxies_priv. To dump any of the grant tables, name themysql database followed by the table names:

mysqlpump mysql user db ...