1MYSQLDUMP(1)                 MySQL Database System                MYSQLDUMP(1)
2
3
4

NAME

6       mysqldump - a database backup program
7

SYNOPSIS

9       mysqldump [options] [db_name [tbl_name ...]]
10

DESCRIPTION

12       The mysqldump client utility performs logical backups, producing a set
13       of SQL statements that can be executed to reproduce the original
14       database object definitions and table data. It dumps one or more MySQL
15       databases for backup or transfer to another SQL server. The mysqldump
16       command can also generate output in CSV, other delimited text, or XML
17       format.
18
19       ·   Performance and Scalability Considerations
20
21       ·   Invocation Syntax
22
23       ·   Option Syntax - Alphabetical Summary
24
25       ·   Connection Options
26
27       ·   Option-File Options
28
29       ·   DDL Options
30
31       ·   Debug Options
32
33       ·   Help Options
34
35       ·   Internationalization Options
36
37       ·   Replication Options
38
39       ·   Format Options
40
41       ·   Filtering Options
42
43       ·   Performance Options
44
45       ·   Transactional Options
46
47       ·   Option Groups
48
49       ·   Examples
50
51       ·   Restrictions
52
53       mysqldump requires at least the SELECT privilege for dumped tables,
54       SHOW VIEW for dumped views, TRIGGER for dumped triggers, and LOCK
55       TABLES if the --single-transaction option is not used. Certain options
56       might require other privileges as noted in the option descriptions.
57
58       To reload a dump file, you must have the privileges required to execute
59       the statements that it contains, such as the appropriate CREATE
60       privileges for objects created by those statements.
61
62       mysqldump output can include ALTER DATABASE statements that change the
63       database collation. These may be used when dumping stored programs to
64       preserve their character encodings. To reload a dump file containing
65       such statements, the ALTER privilege for the affected database is
66       required.
67
68           Note
69           A dump made using PowerShell on Windows with output redirection
70           creates a file that has UTF-16 encoding:
71
72               shell> mysqldump [options] > dump.sql
73
74           However, UTF-16 is not permitted as a connection character set (see
75           the section called “Impermissible Client Character Sets”), so the
76           dump file will not load correctly. To work around this issue, use
77           the --result-file option, which creates the output in ASCII format:
78
79               shell> mysqldump [options] --result-file=dump.sql
80       Performance and Scalability Considerations
81
82       mysqldump advantages include the convenience and flexibility of viewing
83       or even editing the output before restoring. You can clone databases
84       for development and DBA work, or produce slight variations of an
85       existing database for testing. It is not intended as a fast or scalable
86       solution for backing up substantial amounts of data. With large data
87       sizes, even if the backup step takes a reasonable time, restoring the
88       data can be very slow because replaying the SQL statements involves
89       disk I/O for insertion, index creation, and so on.
90
91       For large-scale backup and restore, a physical backup is more
92       appropriate, to copy the data files in their original format that can
93       be restored quickly:
94
95       ·   If your tables are primarily InnoDB tables, or if you have a mix of
96           InnoDB and MyISAM tables, consider using the mysqlbackup command of
97           the MySQL Enterprise Backup product. (Available as part of the
98           Enterprise subscription.) It provides the best performance for
99           InnoDB backups with minimal disruption; it can also back up tables
100           from MyISAM and other storage engines; and it provides a number of
101           convenient options to accommodate different backup scenarios. See
102           Section 30.2, “MySQL Enterprise Backup Overview”.
103
104       mysqldump can retrieve and dump table contents row by row, or it can
105       retrieve the entire content from a table and buffer it in memory before
106       dumping it. Buffering in memory can be a problem if you are dumping
107       large tables. To dump tables row by row, use the --quick option (or
108       --opt, which enables --quick). The --opt option (and hence --quick) is
109       enabled by default, so to enable memory buffering, use --skip-quick.
110
111       If you are using a recent version of mysqldump to generate a dump to be
112       reloaded into a very old MySQL server, use the --skip-opt option
113       instead of the --opt or --extended-insert option.
114
115       For additional information about mysqldump, see Section 7.4, “Using
116       mysqldump for Backups”.  Invocation Syntax
117
118       There are in general three ways to use mysqldump—in order to dump a set
119       of one or more tables, a set of one or more complete databases, or an
120       entire MySQL server—as shown here:
121
122           shell> mysqldump [options] db_name [tbl_name ...]
123           shell> mysqldump [options] --databases db_name ...
124           shell> mysqldump [options] --all-databases
125
126       To dump entire databases, do not name any tables following db_name, or
127       use the --databases or --all-databases option.
128
129       To see a list of the options your version of mysqldump supports, issue
130       the command mysqldump --help.  Option Syntax - Alphabetical Summary
131
132       mysqldump supports the following options, which can be specified on the
133       command line or in the [mysqldump] and [client] groups of an option
134       file. For information about option files used by MySQL programs, see
135       Section 4.2.2.2, “Using Option Files”.  Connection Options
136
137       The mysqldump command logs into a MySQL server to extract information.
138       The following options specify how to connect to the MySQL server,
139       either on the same machine or a remote system.
140
141       ·   --bind-address=ip_address
142
143           On a computer having multiple network interfaces, use this option
144           to select which interface to use for connecting to the MySQL
145           server.
146
147       ·   --compress, -C
148
149           Compress all information sent between the client and the server if
150           possible. See Section 4.2.6, “Connection Compression Control”.
151
152           As of MySQL 8.0.18, this option is deprecated. It will be removed
153           in a future MySQL version. See the section called “Legacy
154           Connection Compression Configuration”.
155
156       ·   --compression-algorithms=value The permitted compression algorithms
157           for connections to the server. The available algorithms are the
158           same as for the protocol_compression_algorithms system variable.
159           The default value is uncompressed.
160
161           For more information, see Section 4.2.6, “Connection Compression
162           Control”.
163
164           This option was added in MySQL 8.0.18.
165
166       ·   --default-auth=plugin
167
168           A hint about which client-side authentication plugin to use. See
169           Section 6.2.17, “Pluggable Authentication”.
170
171       ·   --enable-cleartext-plugin
172
173           Enable the mysql_clear_password cleartext authentication plugin.
174           (See Section 6.4.1.4, “Client-Side Cleartext Pluggable
175           Authentication”.)
176
177       ·   --get-server-public-key
178
179           Request from the server the public key required for RSA key
180           pair-based password exchange. This option applies to clients that
181           authenticate with the caching_sha2_password authentication plugin.
182           For that plugin, the server does not send the public key unless
183           requested. This option is ignored for accounts that do not
184           authenticate with that plugin. It is also ignored if RSA-based
185           password exchange is not used, as is the case when the client
186           connects to the server using a secure connection.
187
188           If --server-public-key-path=file_name is given and specifies a
189           valid public key file, it takes precedence over
190           --get-server-public-key.
191
192           For information about the caching_sha2_password plugin, see
193           Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
194
195       ·   --host=host_name, -h host_name
196
197           Dump data from the MySQL server on the given host. The default host
198           is localhost.
199
200       ·   --login-path=name
201
202           Read options from the named login path in the .mylogin.cnf login
203           path file. A “login path” is an option group containing options
204           that specify which MySQL server to connect to and which account to
205           authenticate as. To create or modify a login path file, use the
206           mysql_config_editor utility. See mysql_config_editor(1).
207
208           For additional information about this and other option-file
209           options, see Section 4.2.2.3, “Command-Line Options that Affect
210           Option-File Handling”.
211
212       ·   --password[=password], -p[password]
213
214           The password of the MySQL account used for connecting to the
215           server. The password value is optional. If not given, mysqldump
216           prompts for one. If given, there must be no space between
217           --password= or -p and the password following it. If no password
218           option is specified, the default is to send no password.
219
220           Specifying a password on the command line should be considered
221           insecure. To avoid giving the password on the command line, use an
222           option file. See Section 6.1.2.1, “End-User Guidelines for Password
223           Security”.
224
225           To explicitly specify that there is no password and that mysqldump
226           should not prompt for one, use the --skip-password option.
227
228       ·   --pipe, -W
229
230           On Windows, connect to the server using a named pipe. This option
231           applies only if the server was started with the named_pipe system
232           variable enabled to support named-pipe connections. In addition,
233           the user making the connection must be a member of the Windows
234           group specified by the named_pipe_full_access_group system
235           variable.
236
237       ·   --plugin-dir=dir_name
238
239           The directory in which to look for plugins. Specify this option if
240           the --default-auth option is used to specify an authentication
241           plugin but mysqldump does not find it. See Section 6.2.17,
242           “Pluggable Authentication”.
243
244       ·   --port=port_num, -P port_num
245
246           For TCP/IP connections, the port number to use.
247
248       ·   --protocol={TCP|SOCKET|PIPE|MEMORY}
249
250           The connection protocol to use for connecting to the server. It is
251           useful when the other connection parameters normally result in use
252           of a protocol other than the one you want. For details on the
253           permissible values, see Section 4.2.4, “Connecting to the MySQL
254           Server Using Command Options”.
255
256       ·   --server-public-key-path=file_name
257
258           The path name to a file containing a client-side copy of the public
259           key required by the server for RSA key pair-based password
260           exchange. The file must be in PEM format. This option applies to
261           clients that authenticate with the sha256_password or
262           caching_sha2_password authentication plugin. This option is ignored
263           for accounts that do not authenticate with one of those plugins. It
264           is also ignored if RSA-based password exchange is not used, as is
265           the case when the client connects to the server using a secure
266           connection.
267
268           If --server-public-key-path=file_name is given and specifies a
269           valid public key file, it takes precedence over
270           --get-server-public-key.
271
272           For sha256_password, this option applies only if MySQL was built
273           using OpenSSL.
274
275           For information about the sha256_password and caching_sha2_password
276           plugins, see Section 6.4.1.3, “SHA-256 Pluggable Authentication”,
277           and Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
278
279       ·   --socket=path, -S path
280
281           For connections to localhost, the Unix socket file to use, or, on
282           Windows, the name of the named pipe to use.
283
284           On Windows, this option applies only if the server was started with
285           the named_pipe system variable enabled to support named-pipe
286           connections. In addition, the user making the connection must be a
287           member of the Windows group specified by the
288           named_pipe_full_access_group system variable.
289
290       ·   --ssl*
291
292           Options that begin with --ssl specify whether to connect to the
293           server using SSL and indicate where to find SSL keys and
294           certificates. See the section called “Command Options for Encrypted
295           Connections”.
296
297       ·   --ssl-fips-mode={OFF|ON|STRICT} Controls whether to enable FIPS
298           mode on the client side. The --ssl-fips-mode option differs from
299           other --ssl-xxx options in that it is not used to establish
300           encrypted connections, but rather to affect which cryptographic
301           operations are permitted. See Section 6.5, “FIPS Support”.
302
303           These --ssl-fips-mode values are permitted:
304
305           ·   OFF: Disable FIPS mode.
306
307           ·   ON: Enable FIPS mode.
308
309           ·   STRICT: Enable “strict” FIPS mode.
310
311
312               Note
313               If the OpenSSL FIPS Object Module is not available, the only
314               permitted value for --ssl-fips-mode is OFF. In this case,
315               setting --ssl-fips-mode to ON or STRICT causes the client to
316               produce a warning at startup and to operate in non-FIPS mode.
317
318       ·   --tls-ciphersuites=ciphersuite_list
319
320           The permissible ciphersuites for encrypted connections that use
321           TLSv1.3. The value is a list of one or more colon-separated
322           ciphersuite names. The ciphersuites that can be named for this
323           option depend on the SSL library used to compile MySQL. For
324           details, see Section 6.3.2, “Encrypted Connection TLS Protocols and
325           Ciphers”.
326
327           This option was added in MySQL 8.0.16.
328
329       ·   --tls-version=protocol_list
330
331           The permissible TLS protocols for encrypted connections. The value
332           is a list of one or more comma-separated protocol names. The
333           protocols that can be named for this option depend on the SSL
334           library used to compile MySQL. For details, see Section 6.3.2,
335           “Encrypted Connection TLS Protocols and Ciphers”.
336
337       ·   --user=user_name, -u user_name
338
339           The user name of the MySQL account to use for connecting to the
340           server.
341
342       ·   --zstd-compression-level=level The compression level to use for
343           connections to the server that use the zstd compression algorithm.
344           The permitted levels are from 1 to 22, with larger values
345           indicating increasing levels of compression. The default zstd
346           compression level is 3. The compression level setting has no effect
347           on connections that do not use zstd compression.
348
349           For more information, see Section 4.2.6, “Connection Compression
350           Control”.
351
352           This option was added in MySQL 8.0.18.
353       Option-File Options
354
355       These options are used to control which option files to read.
356
357       ·   --defaults-extra-file=file_name
358
359           Read this option file after the global option file but (on Unix)
360           before the user option file. If the file does not exist or is
361           otherwise inaccessible, an error occurs.  file_name is interpreted
362           relative to the current directory if given as a relative path name
363           rather than a full path name.
364
365           For additional information about this and other option-file
366           options, see Section 4.2.2.3, “Command-Line Options that Affect
367           Option-File Handling”.
368
369       ·   --defaults-file=file_name
370
371           Use only the given option file. If the file does not exist or is
372           otherwise inaccessible, an error occurs.  file_name is interpreted
373           relative to the current directory if given as a relative path name
374           rather than a full path name.
375
376           Exception: Even with --defaults-file, client programs read
377           .mylogin.cnf.
378
379           For additional information about this and other option-file
380           options, see Section 4.2.2.3, “Command-Line Options that Affect
381           Option-File Handling”.
382
383       ·   --defaults-group-suffix=str
384
385           Read not only the usual option groups, but also groups with the
386           usual names and a suffix of str. For example, mysqldump normally
387           reads the [client] and [mysqldump] groups. If the
388           --defaults-group-suffix=_other option is given, mysqldump also
389           reads the [client_other] and [mysqldump_other] groups.
390
391           For additional information about this and other option-file
392           options, see Section 4.2.2.3, “Command-Line Options that Affect
393           Option-File Handling”.
394
395       ·   --no-defaults
396
397           Do not read any option files. If program startup fails due to
398           reading unknown options from an option file, --no-defaults can be
399           used to prevent them from being read.
400
401           The exception is that the .mylogin.cnf file, if it exists, is read
402           in all cases. This permits passwords to be specified in a safer way
403           than on the command line even when --no-defaults is used.
404           (.mylogin.cnf is created by the mysql_config_editor utility. See
405           mysql_config_editor(1).)
406
407           For additional information about this and other option-file
408           options, see Section 4.2.2.3, “Command-Line Options that Affect
409           Option-File Handling”.
410
411       ·   --print-defaults
412
413           Print the program name and all options that it gets from option
414           files.
415
416           For additional information about this and other option-file
417           options, see Section 4.2.2.3, “Command-Line Options that Affect
418           Option-File Handling”.
419       DDL Options
420
421       Usage scenarios for mysqldump include setting up an entire new MySQL
422       instance (including database tables), and replacing data inside an
423       existing instance with existing databases and tables. The following
424       options let you specify which things to tear down and set up when
425       restoring a dump, by encoding various DDL statements within the dump
426       file.
427
428       ·   --add-drop-database
429
430           Write a DROP DATABASE statement before each CREATE DATABASE
431           statement. This option is typically used in conjunction with the
432           --all-databases or --databases option because no CREATE DATABASE
433           statements are written unless one of those options is specified.
434
435       ·   --add-drop-table
436
437           Write a DROP TABLE statement before each CREATE TABLE statement.
438
439       ·   --add-drop-trigger
440
441           Write a DROP TRIGGER statement before each CREATE TRIGGER
442           statement.
443
444       ·   --all-tablespaces, -Y
445
446           Adds to a table dump all SQL statements needed to create any
447           tablespaces used by an NDB table. This information is not otherwise
448           included in the output from mysqldump. This option is currently
449           relevant only to NDB Cluster tables.
450
451       ·   --no-create-db, -n
452
453           Suppress the CREATE DATABASE statements that are otherwise included
454           in the output if the --databases or --all-databases option is
455           given.
456
457       ·   --no-create-info, -t
458
459           Do not write CREATE TABLE statements that create each dumped table.
460
461               Note
462               This option does not exclude statements creating log file
463               groups or tablespaces from mysqldump output; however, you can
464               use the --no-tablespaces option for this purpose.
465
466       ·   --no-tablespaces, -y
467
468           This option suppresses all CREATE LOGFILE GROUP and CREATE
469           TABLESPACE statements in the output of mysqldump.
470
471       ·   --replace
472
473           Write REPLACE statements rather than INSERT statements.
474       Debug Options
475
476       The following options print debugging information, encode debugging
477       information in the dump file, or let the dump operation proceed
478       regardless of potential problems.
479
480       ·   --allow-keywords
481
482           Permit creation of column names that are keywords. This works by
483           prefixing each column name with the table name.
484
485       ·   --comments, -i
486
487           Write additional information in the dump file such as program
488           version, server version, and host. This option is enabled by
489           default. To suppress this additional information, use
490           --skip-comments.
491
492       ·   --debug[=debug_options], -# [debug_options]
493
494           Write a debugging log. A typical debug_options string is
495           d:t:o,file_name. The default value is d:t:o,/tmp/mysqldump.trace.
496
497           This option is available only if MySQL was built using WITH_DEBUG.
498           MySQL release binaries provided by Oracle are not built using this
499           option.
500
501       ·   --debug-check
502
503           Print some debugging information when the program exits.
504
505           This option is available only if MySQL was built using WITH_DEBUG.
506           MySQL release binaries provided by Oracle are not built using this
507           option.
508
509       ·   --debug-info
510
511           Print debugging information and memory and CPU usage statistics
512           when the program exits.
513
514           This option is available only if MySQL was built using WITH_DEBUG.
515           MySQL release binaries provided by Oracle are not built using this
516           option.
517
518       ·   --dump-date
519
520           If the --comments option is given, mysqldump produces a comment at
521           the end of the dump of the following form:
522
523               -- Dump completed on DATE
524
525           However, the date causes dump files taken at different times to
526           appear to be different, even if the data are otherwise identical.
527           --dump-date and --skip-dump-date control whether the date is added
528           to the comment. The default is --dump-date (include the date in the
529           comment).  --skip-dump-date suppresses date printing.
530
531       ·   --force, -f
532
533           Ignore all errors; continue even if an SQL error occurs during a
534           table dump.
535
536           One use for this option is to cause mysqldump to continue executing
537           even when it encounters a view that has become invalid because the
538           definition refers to a table that has been dropped. Without
539           --force, mysqldump exits with an error message. With --force,
540           mysqldump prints the error message, but it also writes an SQL
541           comment containing the view definition to the dump output and
542           continues executing.
543
544           If the --ignore-error option is also given to ignore specific
545           errors, --force takes precedence.
546
547       ·   --log-error=file_name
548
549           Log warnings and errors by appending them to the named file. The
550           default is to do no logging.
551
552       ·   --skip-comments
553
554           See the description for the --comments option.
555
556       ·   --verbose, -v
557
558           Verbose mode. Print more information about what the program does.
559       Help Options
560
561       The following options display information about the mysqldump command
562       itself.
563
564       ·   --help, -?
565
566           Display a help message and exit.
567
568       ·   --version, -V
569
570           Display version information and exit.
571       Internationalization Options
572
573       The following options change how the mysqldump command represents
574       character data with national language settings.
575
576       ·   --character-sets-dir=dir_name
577
578           The directory where character sets are installed. See
579           Section 10.15, “Character Set Configuration”.
580
581       ·   --default-character-set=charset_name
582
583           Use charset_name as the default character set. See Section 10.15,
584           “Character Set Configuration”. If no character set is specified,
585           mysqldump uses utf8.
586
587       ·   --no-set-names, -N
588
589           Turns off the --set-charset setting, the same as specifying
590           --skip-set-charset.
591
592       ·   --set-charset
593
594           Write SET NAMES default_character_set to the output. This option is
595           enabled by default. To suppress the SET NAMES statement, use
596           --skip-set-charset.
597       Replication Options
598
599       The mysqldump command is frequently used to create an empty instance,
600       or an instance including data, on a slave server in a replication
601       configuration. The following options apply to dumping and restoring
602       data on replication master and slave servers.
603
604       ·   --apply-slave-statements
605
606           For a slave dump produced with the --dump-slave option, add a STOP
607           SLAVE statement before the CHANGE MASTER TO statement and a START
608           SLAVE statement at the end of the output.
609
610       ·   --delete-master-logs
611
612           On a master replication server, delete the binary logs by sending a
613           PURGE BINARY LOGS statement to the server after performing the dump
614           operation. This option automatically enables --master-data.
615
616       ·   --dump-slave[=value]
617
618           This option is similar to --master-data except that it is used to
619           dump a replication slave server to produce a dump file that can be
620           used to set up another server as a slave that has the same master
621           as the dumped server. It causes the dump output to include a CHANGE
622           MASTER TO statement that indicates the binary log coordinates (file
623           name and position) of the dumped slave's master. The CHANGE MASTER
624           TO statement reads the values of Relay_Master_Log_File and
625           Exec_Master_Log_Pos from the SHOW SLAVE STATUS output and uses them
626           for MASTER_LOG_FILE and MASTER_LOG_POS respectively. These are the
627           master server coordinates from which the slave should start
628           replicating.
629
630               Note
631               Inconsistencies in the sequence of transactions from the relay
632               log which have been executed can cause the wrong position to be
633               used. See Section 17.5.1.33, “Replication and Transaction
634               Inconsistencies” for more information.
635           --dump-slave causes the coordinates from the master to be used
636           rather than those of the dumped server, as is done by the
637           --master-data option. In addition, specfiying this option causes
638           the --master-data option to be overridden, if used, and effectively
639           ignored.
640
641               Warning
642               This option should not be used if the server where the dump is
643               going to be applied uses gtid_mode=ON and
644               MASTER_AUTOPOSITION=1.
645           The option value is handled the same way as for --master-data
646           (setting no value or 1 causes a CHANGE MASTER TO statement to be
647           written to the dump, setting 2 causes the statement to be written
648           but encased in SQL comments) and has the same effect as
649           --master-data in terms of enabling or disabling other options and
650           in how locking is handled.
651
652           This option causes mysqldump to stop the slave SQL thread before
653           the dump and restart it again after.
654
655           In conjunction with --dump-slave, the --apply-slave-statements and
656           --include-master-host-port options can also be used.
657
658       ·   --include-master-host-port
659
660           For the CHANGE MASTER TO statement in a slave dump produced with
661           the --dump-slave option, add MASTER_HOST and MASTER_PORT options
662           for the host name and TCP/IP port number of the slave's master.
663
664       ·   --master-data[=value]
665
666           Use this option to dump a master replication server to produce a
667           dump file that can be used to set up another server as a slave of
668           the master. It causes the dump output to include a CHANGE MASTER TO
669           statement that indicates the binary log coordinates (file name and
670           position) of the dumped server. These are the master server
671           coordinates from which the slave should start replicating after you
672           load the dump file into the slave.
673
674           If the option value is 2, the CHANGE MASTER TO statement is written
675           as an SQL comment, and thus is informative only; it has no effect
676           when the dump file is reloaded. If the option value is 1, the
677           statement is not written as a comment and takes effect when the
678           dump file is reloaded. If no option value is specified, the default
679           value is 1.
680
681           This option requires the RELOAD privilege and the binary log must
682           be enabled.
683
684           The --master-data option automatically turns off --lock-tables. It
685           also turns on --lock-all-tables, unless --single-transaction also
686           is specified, in which case, a global read lock is acquired only
687           for a short time at the beginning of the dump (see the description
688           for --single-transaction). In all cases, any action on logs happens
689           at the exact moment of the dump.
690
691           It is also possible to set up a slave by dumping an existing slave
692           of the master, using the --dump-slave option, which overrides
693           --master-data and causes it to be ignored if both options are used.
694
695       ·   --set-gtid-purged=value
696
697           This option is for servers that use GTID-based replication
698           (gtid_mode=ON). It controls the inclusion of a SET
699           @@GLOBAL.gtid_purged statement in the dump output, which updates
700           the value of gtid_purged on a server where the dump file is
701           reloaded, to add the GTID set from the source server's
702           gtid_executed system variable.  gtid_purged holds the GTIDs of all
703           transactions that have been applied on the server, but do not exist
704           on any binary log file on the server.  mysqldump therefore adds the
705           GTIDs for the transactions that were executed on the source server,
706           so that the target server records these transactions as applied,
707           although it does not have them in its binary logs.
708           --set-gtid-purged also controls the inclusion of a SET
709           @@SESSION.sql_log_bin=0 statement, which disables binary logging
710           while the dump file is being reloaded. This statement prevents new
711           GTIDs from being generated and assigned to the transactions in the
712           dump file as they are executed, so that the original GTIDs for the
713           transactions are used.
714
715           If you do not set the --set-gtid-purged option, the default is that
716           a SET @@GLOBAL.gtid_purged statement is included in the dump output
717           if GTIDs are enabled on the server you are backing up, and the set
718           of GTIDs in the global value of the gtid_executed system variable
719           is not empty. A SET @@SESSION.sql_log_bin=0 statement is also
720           included if GTIDs are enabled on the server.
721
722           In MySQL 5.6 and 5.7, you can replace the value of gtid_purged with
723           a specified GTID set, provided that gtid_executed and gtid_purged
724           are empty. From MySQL 8.0, you can either replace the value of
725           gtid_purged with a specified GTID set, or you can add a plus sign
726           (+) to the statement to append a specified GTID set to the GTID set
727           that is already held by gtid_purged.  mysqldump's SET
728           @@GLOBAL.gtid_purged statement includes a plus sign (+) in a
729           version comment that takes effect when the dump file is replayed on
730           releases from MySQL 8.0, meaning that for these releases, the GTID
731           set from the dump file is added to the existing gtid_purged value.
732           For MySQL 5.6 and 5.7, the value of gtid_purged is replaced with
733           the GTID set from the dump file, which can only happen when
734           gtid_executed is the empty set (so when replication has not been
735           started previously, or when replication was not previously using
736           GTIDs). For the exact details of how the SET @@GLOBAL.gtid_purged
737           statement operates, see the gtid_purged description for the release
738           where the dump file is to be replayed.
739
740           It is important to note that the value that is included by
741           mysqldump for the SET @@GLOBAL.gtid_purged statement includes the
742           GTIDs of all transactions in the gtid_executed set on the server,
743           even those that changed suppressed parts of the database, or other
744           databases on the server that were not included in a partial dump.
745           This can mean that after the gtid_purged value has been updated on
746           the server where the dump file is replayed, GTIDs are present that
747           do not relate to any data on the target server. If you do not
748           replay any further dump files on the target server, the extraneous
749           GTIDs do not cause any problems with the future operation of the
750           server, but they make it harder to compare or reconcile GTID sets
751           on different servers in the replication topology. If you do replay
752           a further dump file on the target server that contains the same
753           GTIDs (for example, another partial dump from the same origin
754           server), any SET @@GLOBAL.gtid_purged statement in the second dump
755           file fails. In this case, either remove the statement manually
756           before replaying the dump file, or output the dump file without the
757           statement.
758
759               Note
760               For MySQL 5.6 and 5.7, it is not recommended to load a dump
761               file when GTIDs are enabled on the server (gtid_mode=ON), if
762               your dump file includes system tables.  mysqldump issues DML
763               instructions for the system tables which use the
764               non-transactional MyISAM storage engine, and this combination
765               is not permitted when GTIDs are enabled.
766           If the SET @@GLOBAL.gtid_purged statement would not have the
767           desired result on your target server, you can exclude the statement
768           from the output, or (from MySQL 8.0.17) include it but comment it
769           out so that it is not actioned automatically. You can also include
770           the statement but manually edit it in the dump file to achieve the
771           desired result.
772
773           The possible values for the --set-gtid-purged option are as
774           follows:
775
776           AUTO
777               The default value. If GTIDs are enabled on the server you are
778               backing up and gtid_executed is not empty, SET
779               @@GLOBAL.gtid_purged is added to the output, containing the
780               GTID set from gtid_executed. If GTIDs are enabled, SET
781               @@SESSION.sql_log_bin=0 is added to the output. If GTIDs are
782               not enabled on the server, the statements are not added to the
783               output.
784
785           OFF
786               SET @@GLOBAL.gtid_purged is not added to the output, and SET
787               @@SESSION.sql_log_bin=0 is not added to the output. For a
788               server where GTIDs are not in use, use this option or AUTO.
789               Only use this option for a server where GTIDs are in use if you
790               are sure that the required GTID set is already present in
791               gtid_purged on the target server and should not be changed, or
792               if you plan to identify and add any missing GTIDs manually.
793
794           ON
795               If GTIDs are enabled on the server you are backing up, SET
796               @@GLOBAL.gtid_purged is added to the output (unless
797               gtid_executed is empty), and SET @@SESSION.sql_log_bin=0 is
798               added to the output. An error occurs if you set this option but
799               GTIDs are not enabled on the server. For a server where GTIDs
800               are in use, use this option or AUTO, unless you are sure that
801               the GTIDs in gtid_executed are not needed on the target server.
802
803           COMMENTED
804               Available from MySQL 8.0.17. If GTIDs are enabled on the server
805               you are backing up, SET @@GLOBAL.gtid_purged is added to the
806               output (unless gtid_executed is empty), but it is commented
807               out. This means that the value of gtid_executed is available in
808               the output, but no action is taken automatically when the dump
809               file is reloaded.  SET @@SESSION.sql_log_bin=0 is added to the
810               output, and it is not commented out. With COMMENTED, you can
811               control the use of the gtid_executed set manually or through
812               automation. For example, you might prefer to do this if you are
813               migrating data to another server that already has different
814               active databases.
815       Format Options
816
817       The following options specify how to represent the entire dump file or
818       certain kinds of data in the dump file. They also control whether
819       certain optional information is written to the dump file.
820
821       ·   --compact
822
823           Produce more compact output. This option enables the
824           --skip-add-drop-table, --skip-add-locks, --skip-comments,
825           --skip-disable-keys, and --skip-set-charset options.
826
827       ·   --compatible=name
828
829           Produce output that is more compatible with other database systems
830           or with older MySQL servers. The only permitted value for this
831           option is ansi, which has the same meaning as the corresponding
832           option for setting the server SQL mode. See Section 5.1.11, “Server
833           SQL Modes”.
834
835       ·   --complete-insert, -c
836
837           Use complete INSERT statements that include column names.
838
839       ·   --create-options
840
841           Include all MySQL-specific table options in the CREATE TABLE
842           statements.
843
844       ·   --fields-terminated-by=..., --fields-enclosed-by=...,
845           --fields-optionally-enclosed-by=..., --fields-escaped-by=...
846
847           These options are used with the --tab option and have the same
848           meaning as the corresponding FIELDS clauses for LOAD DATA. See
849           Section 13.2.7, “LOAD DATA Statement”.
850
851       ·   --hex-blob
852
853           Dump binary columns using hexadecimal notation (for example, 'abc'
854           becomes 0x616263). The affected data types are BINARY, VARBINARY,
855           BLOB types, BIT, all spatial data types, and other non-binary data
856           types when used with the binary character set.
857
858       ·   --lines-terminated-by=...
859
860           This option is used with the --tab option and has the same meaning
861           as the corresponding LINES clause for LOAD DATA. See
862           Section 13.2.7, “LOAD DATA Statement”.
863
864       ·   --quote-names, -Q
865
866           Quote identifiers (such as database, table, and column names)
867           within ` characters. If the ANSI_QUOTES SQL mode is enabled,
868           identifiers are quoted within " characters. This option is enabled
869           by default. It can be disabled with --skip-quote-names, but this
870           option should be given after any option such as --compatible that
871           may enable --quote-names.
872
873       ·   --result-file=file_name, -r file_name
874
875           Direct output to the named file. The result file is created and its
876           previous contents overwritten, even if an error occurs while
877           generating the dump.
878
879           This option should be used on Windows to prevent newline \n
880           characters from being converted to \r\n carriage return/newline
881           sequences.
882
883       ·   --show-create-skip-secondary-engine=value Excludes the SECONDARY
884           ENGINE clause from CREATE TABLE statements. It does so by enabling
885           the show_create_table_skip_secondary_engine system variable for the
886           duration of the dump operation. Alternatively, you can enable the
887           show_create_table_skip_secondary_engine system variable prior to
888           using mysqldump.
889
890           This option was added in MySQL 8.0.18. Attempting a mysqldump
891           operation with the --show-create-skip-secondary-engine option on a
892           release prior to MySQL 8.0.18 that does not support the
893           show_create_table_skip_secondary_engine variable causes an error.
894
895       ·   --tab=dir_name, -T dir_name
896
897           Produce tab-separated text-format data files. For each dumped
898           table, mysqldump creates a tbl_name.sql file that contains the
899           CREATE TABLE statement that creates the table, and the server
900           writes a tbl_name.txt file that contains its data. The option value
901           is the directory in which to write the files.
902
903               Note
904               This option should be used only when mysqldump is run on the
905               same machine as the mysqld server. Because the server creates
906               *.txt files in the directory that you specify, the directory
907               must be writable by the server and the MySQL account that you
908               use must have the FILE privilege. Because mysqldump creates
909               *.sql in the same directory, it must be writable by your system
910               login account.
911           By default, the .txt data files are formatted using tab characters
912           between column values and a newline at the end of each line. The
913           format can be specified explicitly using the --fields-xxx and
914           --lines-terminated-by options.
915
916           Column values are converted to the character set specified by the
917           --default-character-set option.
918
919       ·   --tz-utc
920
921           This option enables TIMESTAMP columns to be dumped and reloaded
922           between servers in different time zones.  mysqldump sets its
923           connection time zone to UTC and adds SET TIME_ZONE='+00:00' to the
924           dump file. Without this option, TIMESTAMP columns are dumped and
925           reloaded in the time zones local to the source and destination
926           servers, which can cause the values to change if the servers are in
927           different time zones.  --tz-utc also protects against changes due
928           to daylight saving time.  --tz-utc is enabled by default. To
929           disable it, use --skip-tz-utc.
930
931       ·   --xml, -X
932
933           Write dump output as well-formed XML.
934
935           NULL, 'NULL', and Empty Values: For a column named column_name, the
936           NULL value, an empty string, and the string value 'NULL' are
937           distinguished from one another in the output generated by this
938           option as follows.
939
940           ┌─────────────────────┬────────────────────────────────────────────┐
941Value:               XML Representation:                        
942           ├─────────────────────┼────────────────────────────────────────────┤
943           │NULL (unknown value) │                                            │
944           │                     │            <field                          │
945           │                     │            name="column_name"              │
946           │                     │            xsi:nil="true"                  │
947           │                     │            />                              │
948           ├─────────────────────┼────────────────────────────────────────────┤
949           │                     │                                            │
950           │                     │            <field                          │
951           │                     │            name="column_name"></field>     │
952           ├─────────────────────┼────────────────────────────────────────────┤
953           │                     │                                            │
954           │                     │            <field                          │
955           │                     │            name="column_name">NULL</field> │
956           └─────────────────────┴────────────────────────────────────────────┘
957           The output from the mysql client when run using the --xml option
958           also follows the preceding rules. (See the section called “MYSQL
959           CLIENT OPTIONS”.)
960
961           XML output from mysqldump includes the XML namespace, as shown
962           here:
963
964               shell> mysqldump --xml -u root world City
965               <?xml version="1.0"?>
966               <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
967               <database name="world">
968               <table_structure name="City">
969               <field Field="ID" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
970               <field Field="Name" Type="char(35)" Null="NO" Key="" Default="" Extra="" />
971               <field Field="CountryCode" Type="char(3)" Null="NO" Key="" Default="" Extra="" />
972               <field Field="District" Type="char(20)" Null="NO" Key="" Default="" Extra="" />
973               <field Field="Population" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
974               <key Table="City" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID"
975               Collation="A" Cardinality="4079" Null="" Index_type="BTREE" Comment="" />
976               <options Name="City" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="4079"
977               Avg_row_length="67" Data_length="273293" Max_data_length="18858823439613951"
978               Index_length="43008" Data_free="0" Auto_increment="4080"
979               Create_time="2007-03-31 01:47:01" Update_time="2007-03-31 01:47:02"
980               Collation="latin1_swedish_ci" Create_options="" Comment="" />
981               </table_structure>
982               <table_data name="City">
983               <row>
984               <field name="ID">1</field>
985               <field name="Name">Kabul</field>
986               <field name="CountryCode">AFG</field>
987               <field name="District">Kabol</field>
988               <field name="Population">1780000</field>
989               </row>
990               ...
991               <row>
992               <field name="ID">4079</field>
993               <field name="Name">Rafah</field>
994               <field name="CountryCode">PSE</field>
995               <field name="District">Rafah</field>
996               <field name="Population">92020</field>
997               </row>
998               </table_data>
999               </database>
1000               </mysqldump>
1001       Filtering Options
1002
1003       The following options control which kinds of schema objects are written
1004       to the dump file: by category, such as triggers or events; by name, for
1005       example, choosing which databases and tables to dump; or even filtering
1006       rows from the table data using a WHERE clause.
1007
1008       ·   --all-databases, -A
1009
1010           Dump all tables in all databases. This is the same as using the
1011           --databases option and naming all the databases on the command
1012           line.
1013
1014           Prior to MySQL 8.0, the --routines and --events options for
1015           mysqldump and mysqlpump were not required to include stored
1016           routines and events when using the --all-databases option: The dump
1017           included the mysql system database, and therefore also the
1018           mysql.proc and mysql.event tables containing stored routine and
1019           event definitions. As of MySQL 8.0, the mysql.event and mysql.proc
1020           tables are not used. Definitions for the corresponding objects are
1021           stored in data dictionary tables, but those tables are not dumped.
1022           To include stored routines and events in a dump made using
1023           --all-databases, use the --routines and --events options
1024           explicitly.
1025
1026       ·   --databases, -B
1027
1028           Dump several databases. Normally, mysqldump treats the first name
1029           argument on the command line as a database name and following names
1030           as table names. With this option, it treats all name arguments as
1031           database names.  CREATE DATABASE and USE statements are included in
1032           the output before each new database.
1033
1034           This option may be used to dump the performance_schema database,
1035           which normally is not dumped even with the --all-databases option.
1036           (Also use the --skip-lock-tables option.)
1037
1038       ·   --events, -E
1039
1040           Include Event Scheduler events for the dumped databases in the
1041           output. This option requires the EVENT privileges for those
1042           databases.
1043
1044           The output generated by using --events contains CREATE EVENT
1045           statements to create the events.
1046
1047       ·   --ignore-error=error[,error]...
1048
1049           Ignore the specified errors. The option value is a list of
1050           comma-separated error numbers specifying the errors to ignore
1051           during mysqldump execution. If the --force option is also given to
1052           ignore all errors, --force takes precedence.
1053
1054       ·   --ignore-table=db_name.tbl_name
1055
1056           Do not dump the given table, which must be specified using both the
1057           database and table names. To ignore multiple tables, use this
1058           option multiple times. This option also can be used to ignore
1059           views.
1060
1061       ·   --no-data, -d
1062
1063           Do not write any table row information (that is, do not dump table
1064           contents). This is useful if you want to dump only the CREATE TABLE
1065           statement for the table (for example, to create an empty copy of
1066           the table by loading the dump file).
1067
1068       ·   --routines, -R
1069
1070           Include stored routines (procedures and functions) for the dumped
1071           databases in the output. This option requires the global SELECT
1072           privilege.
1073
1074           The output generated by using --routines contains CREATE PROCEDURE
1075           and CREATE FUNCTION statements to create the routines.
1076
1077       ·   --tables
1078
1079           Override the --databases or -B option.  mysqldump regards all name
1080           arguments following the option as table names.
1081
1082       ·   --triggers
1083
1084           Include triggers for each dumped table in the output. This option
1085           is enabled by default; disable it with --skip-triggers.
1086
1087           To be able to dump a table's triggers, you must have the TRIGGER
1088           privilege for the table.
1089
1090           Multiple triggers are permitted.  mysqldump dumps triggers in
1091           activation order so that when the dump file is reloaded, triggers
1092           are created in the same activation order. However, if a mysqldump
1093           dump file contains multiple triggers for a table that have the same
1094           trigger event and action time, an error occurs for attempts to load
1095           the dump file into an older server that does not support multiple
1096           triggers. (For a workaround, see Downgrade Notes[1]; you can
1097           convert triggers to be compatible with older servers.)
1098
1099       ·   --where='where_condition', -w 'where_condition'
1100
1101           Dump only rows selected by the given WHERE condition. Quotes around
1102           the condition are mandatory if it contains spaces or other
1103           characters that are special to your command interpreter.
1104
1105           Examples:
1106
1107               --where="user='jimf'"
1108               -w"userid>1"
1109               -w"userid<1"
1110       Performance Options
1111
1112       The following options are the most relevant for the performance
1113       particularly of the restore operations. For large data sets, restore
1114       operation (processing the INSERT statements in the dump file) is the
1115       most time-consuming part. When it is urgent to restore data quickly,
1116       plan and test the performance of this stage in advance. For restore
1117       times measured in hours, you might prefer an alternative backup and
1118       restore solution, such as MySQL Enterprise Backup for InnoDB-only and
1119       mixed-use databases.
1120
1121       Performance is also affected by the transactional options, primarily
1122       for the dump operation.
1123
1124       ·   --column-statistics Add ANALYZE TABLE statements to the output to
1125           generate histogram statistics for dumped tables when the dump file
1126           is reloaded. This option is disabled by default because histogram
1127           generation for large tables can take a long time.
1128
1129       ·   --disable-keys, -K
1130
1131           For each table, surround the INSERT statements with /*!40000 ALTER
1132           TABLE tbl_name DISABLE KEYS */; and /*!40000 ALTER TABLE tbl_name
1133           ENABLE KEYS */; statements. This makes loading the dump file faster
1134           because the indexes are created after all rows are inserted. This
1135           option is effective only for nonunique indexes of MyISAM tables.
1136
1137       ·   --extended-insert, -e
1138
1139           Write INSERT statements using multiple-row syntax that includes
1140           several VALUES lists. This results in a smaller dump file and
1141           speeds up inserts when the file is reloaded.
1142
1143       ·   --insert-ignore
1144
1145           Write INSERT IGNORE statements rather than INSERT statements.
1146
1147       ·   --max-allowed-packet=value The maximum size of the buffer for
1148           client/server communication. The default is 24MB, the maximum is
1149           1GB.
1150
1151       ·   --net-buffer-length=value The initial size of the buffer for
1152           client/server communication. When creating multiple-row INSERT
1153           statements (as with the --extended-insert or --opt option),
1154           mysqldump creates rows up to --net-buffer-length bytes long. If you
1155           increase this variable, ensure that the MySQL server
1156           net_buffer_length system variable has a value at least this large.
1157
1158       ·   --network-timeout, -M
1159
1160           Enable large tables to be dumped by setting --max-allowed-packet to
1161           its maximum value and network read and write timeouts to a large
1162           value. This option is enabled by default. To disable it, use
1163           --skip-network-timeout.
1164
1165       ·   --opt
1166
1167           This option, enabled by default, is shorthand for the combination
1168           of --add-drop-table --add-locks --create-options --disable-keys
1169           --extended-insert --lock-tables --quick --set-charset. It gives a
1170           fast dump operation and produces a dump file that can be reloaded
1171           into a MySQL server quickly.
1172
1173           Because the --opt option is enabled by default, you only specify
1174           its converse, the --skip-opt to turn off several default settings.
1175           See the discussion of mysqldump option groups for information about
1176           selectively enabling or disabling a subset of the options affected
1177           by --opt.
1178
1179       ·   --quick, -q
1180
1181           This option is useful for dumping large tables. It forces mysqldump
1182           to retrieve rows for a table from the server a row at a time rather
1183           than retrieving the entire row set and buffering it in memory
1184           before writing it out.
1185
1186       ·   --skip-opt
1187
1188           See the description for the --opt option.
1189       Transactional Options
1190
1191       The following options trade off the performance of the dump operation,
1192       against the reliability and consistency of the exported data.
1193
1194       ·   --add-locks
1195
1196           Surround each table dump with LOCK TABLES and UNLOCK TABLES
1197           statements. This results in faster inserts when the dump file is
1198           reloaded. See Section 8.2.5.1, “Optimizing INSERT Statements”.
1199
1200       ·   --flush-logs, -F
1201
1202           Flush the MySQL server log files before starting the dump. This
1203           option requires the RELOAD privilege. If you use this option in
1204           combination with the --all-databases option, the logs are flushed
1205           for each database dumped. The exception is when using
1206           --lock-all-tables, --master-data, or --single-transaction: In this
1207           case, the logs are flushed only once, corresponding to the moment
1208           that all tables are locked by FLUSH TABLES WITH READ LOCK. If you
1209           want your dump and the log flush to happen at exactly the same
1210           moment, you should use --flush-logs together with
1211           --lock-all-tables, --master-data, or --single-transaction.
1212
1213       ·   --flush-privileges
1214
1215           Add a FLUSH PRIVILEGES statement to the dump output after dumping
1216           the mysql database. This option should be used any time the dump
1217           contains the mysql database and any other database that depends on
1218           the data in the mysql database for proper restoration.
1219
1220
1221               Note
1222               For upgrades to MySQL 5.7.2 or higher from older versions, do
1223               not use --flush-privileges. For upgrade instructions in this
1224               case, see Section 2.11.4, “Changes in MySQL 8.0”.
1225
1226       ·   --lock-all-tables, -x
1227
1228           Lock all tables across all databases. This is achieved by acquiring
1229           a global read lock for the duration of the whole dump. This option
1230           automatically turns off --single-transaction and --lock-tables.
1231
1232       ·   --lock-tables, -l
1233
1234           For each dumped database, lock all tables to be dumped before
1235           dumping them. The tables are locked with READ LOCAL to permit
1236           concurrent inserts in the case of MyISAM tables. For transactional
1237           tables such as InnoDB, --single-transaction is a much better option
1238           than --lock-tables because it does not need to lock the tables at
1239           all.
1240
1241           Because --lock-tables locks tables for each database separately,
1242           this option does not guarantee that the tables in the dump file are
1243           logically consistent between databases. Tables in different
1244           databases may be dumped in completely different states.
1245
1246           Some options, such as --opt, automatically enable --lock-tables. If
1247           you want to override this, use --skip-lock-tables at the end of the
1248           option list.
1249
1250       ·   --no-autocommit
1251
1252           Enclose the INSERT statements for each dumped table within SET
1253           autocommit = 0 and COMMIT statements.
1254
1255       ·   --order-by-primary
1256
1257           Dump each table's rows sorted by its primary key, or by its first
1258           unique index, if such an index exists. This is useful when dumping
1259           a MyISAM table to be loaded into an InnoDB table, but makes the
1260           dump operation take considerably longer.
1261
1262       ·   --shared-memory-base-name=name
1263
1264           On Windows, the shared-memory name to use for connections made
1265           using shared memory to a local server. The default value is MYSQL.
1266           The shared-memory name is case-sensitive.
1267
1268           This option applies only if the server was started with the
1269           shared_memory system variable enabled to support shared-memory
1270           connections.
1271
1272       ·   --single-transaction
1273
1274           This option sets the transaction isolation mode to REPEATABLE READ
1275           and sends a START TRANSACTION SQL statement to the server before
1276           dumping data. It is useful only with transactional tables such as
1277           InnoDB, because then it dumps the consistent state of the database
1278           at the time when START TRANSACTION was issued without blocking any
1279           applications.
1280
1281           When using this option, you should keep in mind that only InnoDB
1282           tables are dumped in a consistent state. For example, any MyISAM or
1283           MEMORY tables dumped while using this option may still change
1284           state.
1285
1286           While a --single-transaction dump is in process, to ensure a valid
1287           dump file (correct table contents and binary log coordinates), no
1288           other connection should use the following statements: ALTER TABLE,
1289           CREATE TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE. A
1290           consistent read is not isolated from those statements, so use of
1291           them on a table to be dumped can cause the SELECT that is performed
1292           by mysqldump to retrieve the table contents to obtain incorrect
1293           contents or fail.
1294
1295           The --single-transaction option and the --lock-tables option are
1296           mutually exclusive because LOCK TABLES causes any pending
1297           transactions to be committed implicitly.
1298
1299           To dump large tables, combine the --single-transaction option with
1300           the --quick option.
1301       Option Groups
1302
1303       ·   The --opt option turns on several settings that work together to
1304           perform a fast dump operation. All of these settings are on by
1305           default, because --opt is on by default. Thus you rarely if ever
1306           specify --opt. Instead, you can turn these settings off as a group
1307           by specifying --skip-opt, the optionally re-enable certain settings
1308           by specifying the associated options later on the command line.
1309
1310       ·   The --compact option turns off several settings that control
1311           whether optional statements and comments appear in the output.
1312           Again, you can follow this option with other options that re-enable
1313           certain settings, or turn all the settings on by using the
1314           --skip-compact form.
1315
1316       When you selectively enable or disable the effect of a group option,
1317       order is important because options are processed first to last. For
1318       example, --disable-keys --lock-tables --skip-opt would not have the
1319       intended effect; it is the same as --skip-opt by itself.  Examples
1320
1321       To make a backup of an entire database:
1322
1323           shell> mysqldump db_name > backup-file.sql
1324
1325       To load the dump file back into the server:
1326
1327           shell> mysql db_name < backup-file.sql
1328
1329       Another way to reload the dump file:
1330
1331           shell> mysql -e "source /path-to-backup/backup-file.sql" db_name
1332
1333       mysqldump is also very useful for populating databases by copying data
1334       from one MySQL server to another:
1335
1336           shell> mysqldump --opt db_name | mysql --host=remote_host -C db_name
1337
1338       You can dump several databases with one command:
1339
1340           shell> mysqldump --databases db_name1 [db_name2 ...] > my_databases.sql
1341
1342       To dump all databases, use the --all-databases option:
1343
1344           shell> mysqldump --all-databases > all_databases.sql
1345
1346       For InnoDB tables, mysqldump provides a way of making an online backup:
1347
1348           shell> mysqldump --all-databases --master-data --single-transaction > all_databases.sql
1349
1350       This backup acquires a global read lock on all tables (using FLUSH
1351       TABLES WITH READ LOCK) at the beginning of the dump. As soon as this
1352       lock has been acquired, the binary log coordinates are read and the
1353       lock is released. If long updating statements are running when the
1354       FLUSH statement is issued, the MySQL server may get stalled until those
1355       statements finish. After that, the dump becomes lock free and does not
1356       disturb reads and writes on the tables. If the update statements that
1357       the MySQL server receives are short (in terms of execution time), the
1358       initial lock period should not be noticeable, even with many updates.
1359
1360       For point-in-time recovery (also known as “roll-forward,” when you need
1361       to restore an old backup and replay the changes that happened since
1362       that backup), it is often useful to rotate the binary log (see
1363       Section 5.4.4, “The Binary Log”) or at least know the binary log
1364       coordinates to which the dump corresponds:
1365
1366           shell> mysqldump --all-databases --master-data=2 > all_databases.sql
1367
1368       Or:
1369
1370           shell> mysqldump --all-databases --flush-logs --master-data=2
1371                         > all_databases.sql
1372
1373       The --master-data and --single-transaction options can be used
1374       simultaneously, which provides a convenient way to make an online
1375       backup suitable for use prior to point-in-time recovery if tables are
1376       stored using the InnoDB storage engine.
1377
1378       For more information on making backups, see Section 7.2, “Database
1379       Backup Methods”, and Section 7.3, “Example Backup and Recovery
1380       Strategy”.
1381
1382       ·   To select the effect of --opt except for some features, use the
1383           --skip option for each feature. To disable extended inserts and
1384           memory buffering, use --opt --skip-extended-insert --skip-quick.
1385           (Actually, --skip-extended-insert --skip-quick is sufficient
1386           because --opt is on by default.)
1387
1388       ·   To reverse --opt for all features except index disabling and table
1389           locking, use --skip-opt --disable-keys --lock-tables.
1390       Restrictions
1391
1392       mysqldump does not dump the performance_schema or sys schema by
1393       default. To dump any of these, name them explicitly on the command
1394       line. You can also name them with the --databases option. For
1395       performance_schema, also use the --skip-lock-tables option.
1396
1397       mysqldump does not dump the INFORMATION_SCHEMA schema.
1398
1399       mysqldump does not dump InnoDB CREATE TABLESPACE statements.
1400
1401       mysqldump does not dump the NDB Cluster ndbinfo information database.
1402
1403       mysqldump includes statements to recreate the general_log and
1404       slow_query_log tables for dumps of the mysql database. Log table
1405       contents are not dumped.
1406
1407       If you encounter problems backing up views due to insufficient
1408       privileges, see Section 24.9, “Restrictions on Views” for a workaround.
1409
1411       Copyright © 1997, 2020, Oracle and/or its affiliates. All rights
1412       reserved.
1413
1414       This documentation is free software; you can redistribute it and/or
1415       modify it only under the terms of the GNU General Public License as
1416       published by the Free Software Foundation; version 2 of the License.
1417
1418       This documentation is distributed in the hope that it will be useful,
1419       but WITHOUT ANY WARRANTY; without even the implied warranty of
1420       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1421       General Public License for more details.
1422
1423       You should have received a copy of the GNU General Public License along
1424       with the program; if not, write to the Free Software Foundation, Inc.,
1425       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
1426       http://www.gnu.org/licenses/.
1427
1428

NOTES

1430        1. Downgrade Notes
1431           https://dev.mysql.com/doc/refman/5.7/en/downgrading-to-previous-series.html
1432

SEE ALSO

1434       For more information, please refer to the MySQL Reference Manual, which
1435       may already be installed locally and which is also available online at
1436       http://dev.mysql.com/doc/.
1437

AUTHOR

1439       Oracle Corporation (http://dev.mysql.com/).
1440
1441
1442
1443MySQL 8.0                         03/06/2020                      MYSQLDUMP(1)
Impressum