1
.\" Title: \fBmysqldump\fR
3
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
5
.\" Manual: MySQL Database System
8
.TH "\fBMYSQLDUMP\fR" "1" "05/23/2009" "MySQL 6.0" "MySQL Database System"
9
.\" disable hyphenation
11
.\" disable justification (adjust text to left margin only)
14
mysqldump \- a database backup program
17
\fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] [\fR\fB\fIdb_name\fR\fR\fB [\fR\fB\fItbl_name\fR\fR\fB ...]]\fR
22
client is a backup program originally written by Igor Romanenko. It can be used to dump a database or a collection of databases for backup or transfer to another SQL server (not necessarily a MySQL server). The dump typically contains SQL statements to create the table, populate it, or both. However,
24
can also be used to generate files in CSV, other delimited text, or XML format.
26
If you are doing a backup on the server and your tables all are
28
tables, consider using the
30
instead because it can accomplish faster backups and faster restores. See
31
\fBmysqlhotcopy\fR(1).
33
There are three general ways to invoke
38
shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR\fB [\fR\fB\fItables\fR\fR\fB]\fR
39
shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \-\-databases \fR\fB\fIdb_name1\fR\fR\fB [\fR\fB\fIdb_name2\fR\fR\fB \fR\fB\fIdb_name3\fR\fR\fB...]\fR
40
shell> \fBmysqldump [\fR\fB\fIoptions\fR\fR\fB] \-\-all\-databases\fR
44
If you do not name any tables following
49
\fB\-\-all\-databases\fR
50
option, entire databases are dumped.
55
database. If you name that database explicitly on the command line,
59
To get a list of the options your version of
62
\fBmysqldump \-\-help\fR.
66
options are shorthand for groups of other options.
70
fall into this category. For example, use of
72
is the same as specifying
73
\fB\-\-add\-drop\-table\fR
75
\fB\-\-create\-options\fR
76
\fB\-\-disable\-keys\fR
77
\fB\-\-extended\-insert\fR
78
\fB\-\-lock\-tables\fR
80
\fB\-\-set\-charset\fR. Note that all of the options that
82
stands for also are on by default because
86
To reverse the effect of a group option, uses its
87
\fB\-\-skip\-\fR\fB\fIxxx\fR\fR
88
form (\fB\-\-skip\-opt\fR
90
\fB\-\-skip\-compact\fR). It is also possible to select only part of the effect of a group option by following it with options that enable or disable specific features. Here are some examples:
93
To select the effect of
95
except for some features, use the
97
option for each feature. For example, to disable extended inserts and memory buffering, use
99
\fB\-\-skip\-extended\-insert\fR
100
\fB\-\-skip\-quick\fR. (As of MySQL 6.0,
101
\fB\-\-skip\-extended\-insert\fR
102
\fB\-\-skip\-quick\fR
103
is sufficient because
110
for all features except index disabling and table locking, use
112
\fB\-\-disable\-keys\fR
113
\fB\-\-lock\-tables\fR.
117
When you selectively enable or disable the effect of a group option, order is important because options are processed first to last. For example,
118
\fB\-\-disable\-keys\fR
119
\fB\-\-lock\-tables\fR
121
would not have the intended effect; it is the same as
126
can retrieve and dump table contents row by row, or it can retrieve the entire content from a table and buffer it in memory before dumping it. Buffering in memory can be a problem if you are dumping large tables. To dump tables row by row, use the
129
\fB\-\-opt\fR, which enables
130
\fB\-\-quick\fR). The
133
\fB\-\-quick\fR) is enabled by default in MySQL 6.0; to enable memory buffering, use
134
\fB\-\-skip\-quick\fR.
136
If you are using a recent version of
138
to generate a dump to be reloaded into a very old MySQL server, you should not use the
141
\fB\-\-extended\-insert\fR
147
supports the options in the following list. It also reads option files and supports the options for processing them described at
148
Section\ 4.2.3.2.1, \(lqCommand\-Line Options that Affect Option\-File Handling\(rq.
154
Display a help message and exit.
157
\fB\-\-add\-drop\-database\fR
161
statement before each
166
\fB\-\-add\-drop\-table\fR
170
statement before each
177
Surround each table dump with
181
statements. This results in faster inserts when the dump file is reloaded. See
182
Section\ 7.2.25, \(lqSpeed of INSERT Statements\(rq.
185
\fB\-\-all\-databases\fR,
188
Dump all tables in all databases. This is the same as using the
190
option and naming all the databases on the command line.
193
\fB\-\-allow\-keywords\fR
195
Allow creation of column names that are keywords. This works by prefixing each column name with the table name.
198
\fB\-\-apply\-slave\-statements\fR
200
For a slave dump produced with the
201
\fB\-\-dump\-slave\fR
208
statement at the end of the output. This option was added in MySQL 6.0.4.
211
\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
213
The directory where character sets are installed. See
214
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq.
220
Write additional information in the dump file such as program version, server version, and host. This option is enabled by default. To suppress this additional information, use
221
\fB\-\-skip\-comments\fR.
226
Produce less verbose output. This option enables the
227
\fB\-\-skip\-add\-drop\-table\fR,
228
\fB\-\-skip\-add\-locks\fR,
229
\fB\-\-skip\-comments\fR,
230
\fB\-\-skip\-disable\-keys\fR, and
231
\fB\-\-skip\-set\-charset\fR
235
\fB\-\-compatible=\fR\fB\fIname\fR\fR
237
Produce output that is more compatible with other database systems or with older MySQL servers. The value of
250
no_field_options. To use several values, separate them by commas. These values have the same meaning as the corresponding options for setting the server SQL mode. See
251
Section\ 5.1.7, \(lqServer SQL Modes\(rq.
253
This option does not guarantee compatibility with other servers. It only enables those SQL mode values that are currently available for making dump output more compatible. For example,
254
\fB\-\-compatible=oracle\fR
255
does not map data types to Oracle types or use Oracle comment syntax.
257
\fIThis option requires a server version of 4.1.0 or higher\fR. With older servers, it does nothing.
260
\fB\-\-complete\-insert\fR,
265
statements that include column names.
271
Compress all information sent between the client and the server if both support compression.
274
\fB\-\-create\-options\fR
276
Include all MySQL\-specific table options in the
284
Dump several databases. Normally,
286
treats the first name argument on the command line as a database name and following names as table names. With this option, it treats all name arguments as database names.
290
statements are included in the output before each new database.
293
\fB\-\-debug[=\fR\fB\fIdebug_options\fR\fR\fB]\fR,
294
\fB\-# [\fR\fB\fIdebug_options\fR\fR\fB]\fR
296
Write a debugging log. A typical
299
\'d:t:o,\fIfile_name\fR'. The default value is
300
\'d:t:o,/tmp/mysqldump.trace'.
303
\fB\-\-debug\-check\fR
305
Print some debugging information when the program exits.
308
\fB\-\-debug\-info\fR
310
Print debugging information and memory and CPU usage statistics when the program exits.
313
\fB\-\-default\-character\-set=\fR\fB\fIcharset_name\fR\fR
317
as the default character set. See
318
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq. If no character set is specified,
321
utf8, and earlier versions use
324
This option has no effect for output data files produced by using the
326
option. See the description for that option.
329
\fB\-\-delayed\-insert\fR
333
statements rather than
338
\fB\-\-delete\-master\-logs\fR
340
On a master replication server, delete the binary logs after performing the dump operation. This option automatically enables
341
\fB\-\-master\-data\fR.
344
\fB\-\-disable\-keys\fR,
347
For each table, surround the
350
/*!40000 ALTER TABLE \fItbl_name\fR DISABLE KEYS */;
352
/*!40000 ALTER TABLE \fItbl_name\fR ENABLE KEYS */;
353
statements. This makes loading the dump file faster because the indexes are created after all rows are inserted. This option is effective only for non\-unique indexes of
362
\-\- Dump completed on \fIDATE\fR
363
comment at the end of the dump if the
365
option is given. However, the date causes dump files for identical data take at different times to appear to be different.
368
\fB\-\-skip\-dump\-date\fR
369
control whether the date is added to the comment. The default is
371
(include the date in the comment).
372
\fB\-\-skip\-dump\-date\fR
373
suppresses date printing. This option was added in MySQL 6.0.4.
376
\fB\-\-dump\-slave[=\fR\fB\fIvalue\fR\fR\fB]\fR
378
This option is similar to
379
\fB\-\-master\-data\fR
380
except that it is used to dump a replication slave server to produce a dump file that can be used to set up another server as a slave that has the same master as the dumped server. It causes the dump output to include a
382
statement that indicates the binary log coordinates (file name and position) of the dumped slave's master (rather than the coordinates of the dumped server, as is done by the
383
\fB\-\-master\-data\fR
384
option). These are the master server coordinates from which the slave should start replicating. This option was added in MySQL 6.0.4.
386
The option value is handled the same way as for
387
\fB\-\-master\-data\fR
388
and has the same effect as
389
\fB\-\-master\-data\fR
390
in terms of enabling or disabling other options and in how locking is handled.
393
\fB\-\-dump\-slave\fR, the
394
\fB\-\-apply\-slave\-statements\fR
396
\fB\-\-include\-master\-host\-port\fR
397
options can also be used.
403
Dump events from the dumped databases.
406
\fB\-\-extended\-insert\fR,
411
syntax that include several
413
lists. This results in a smaller dump file and speeds up inserts when the file is reloaded.
416
\fB\-\-fields\-terminated\-by=...\fR,
417
\fB\-\-fields\-enclosed\-by=...\fR,
418
\fB\-\-fields\-optionally\-enclosed\-by=...\fR,
419
\fB\-\-fields\-escaped\-by=...\fR
421
These options are used with the
423
option and have the same meaning as the corresponding clauses for
424
LOAD DATA INFILE. See
425
Section\ 12.2.6, \(lqLOAD DATA INFILE Syntax\(rq.
428
\fB\-\-first\-slave\fR,
431
Deprecated. Now renamed to
432
\fB\-\-lock\-all\-tables\fR.
435
\fB\-\-flush\-logs\fR,
438
Flush the MySQL server log files before starting the dump. This option requires the
440
privilege. Note that if you use this option in combination with the
441
\fB\-\-all\-databases\fR
443
\fB\-A\fR) option, the logs are flushed
444
\fIfor each database dumped\fR. The exception is when using
445
\fB\-\-lock\-all\-tables\fR
447
\fB\-\-master\-data\fR: In this case, the logs are flushed only once, corresponding to the moment that all tables are locked. If you want your dump and the log flush to happen at exactly the same moment, you should use
448
\fB\-\-flush\-logs\fR
450
\fB\-\-lock\-all\-tables\fR
452
\fB\-\-master\-data\fR.
455
\fB\-\-flush\-privileges\fR
459
statement after dumping the
461
database. This option should be used any time the dump contains the
463
database and any other database that depends on the data in the
465
database for proper restoration.
471
Continue even if an SQL error occurs during a table dump.
473
One use for this option is to cause
475
to continue executing even when it encounters a view that has become invalid because the definition refers to a table that has been dropped. Without
478
exits with an error message. With
481
prints the error message, but it also writes an SQL comment containing the view definition to the dump output and continues executing.
484
\fB\-\-host=\fR\fB\fIhost_name\fR\fR,
485
\fB\-h \fR\fB\fIhost_name\fR\fR
487
Dump data from the MySQL server on the given host. The default host is
493
Dump binary columns using hexadecimal notation (for example,
496
0x616263). The affected data types are
503
\fB\-\-include\-master\-host\-port\fR
507
statement in a slave dump produced with the
508
\fB\-\-dump\-slave\fR
513
options for the host name and TCP/IP port number of the slave's master. This option was added in MySQL 6.0.4.
516
\fB\-\-ignore\-table=\fR\fB\fIdb_name.tbl_name\fR\fR
518
Do not dump the given table, which must be specified using both the database and table names. To ignore multiple tables, use this option multiple times. This option also can be used to ignore views.
521
\fB\-\-insert\-ignore\fR
530
\fB\-\-lines\-terminated\-by=...\fR
532
This option is used with the
534
option and has the same meaning as the corresponding clause for
535
LOAD DATA INFILE. See
536
Section\ 12.2.6, \(lqLOAD DATA INFILE Syntax\(rq.
539
\fB\-\-lock\-all\-tables\fR,
542
Lock all tables across all databases. This is achieved by acquiring a global read lock for the duration of the whole dump. This option automatically turns off
543
\fB\-\-single\-transaction\fR
545
\fB\-\-lock\-tables\fR.
548
\fB\-\-lock\-tables\fR,
551
Lock all tables before dumping them. The tables are locked with
553
to allow concurrent inserts in the case of
555
tables. For transactional tables such as
559
\fB\-\-single\-transaction\fR
560
is a much better option, because it does not need to lock the tables at all.
562
Please note that when dumping multiple databases,
563
\fB\-\-lock\-tables\fR
564
locks tables for each database separately. Therefore, this option does not guarantee that the tables in the dump file are logically consistent between databases. Tables in different databases may be dumped in completely different states.
567
\fB\-\-log\-error=\fR\fB\fIfile_name\fR\fR
569
Append warnings and errors to the named file.
572
\fB\-\-master\-data[=\fR\fB\fIvalue\fR\fR\fB]\fR
574
Use this option to dump a master replication server to produce a dump file that can be used to set up another server as a slave of the master. It causes the dump output to include a
576
statement that indicates the binary log coordinates (file name and position) of the dumped server. These are the master server coordinates from which the slave should start replicating.
578
If the option value is 2, the
580
statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded. If the option value is 1, the statement takes effect when the dump file is reloaded. If the option value is not specified, the default value is 1.
582
This option requires the
584
privilege and the binary log must be enabled.
587
\fB\-\-master\-data\fR
588
option automatically turns off
589
\fB\-\-lock\-tables\fR. It also turns on
590
\fB\-\-lock\-all\-tables\fR, unless
591
\fB\-\-single\-transaction\fR
592
also is specified, in which case, a global read lock is acquired only for a short time at the beginning of the dump (see the description for
593
\fB\-\-single\-transaction\fR). In all cases, any action on logs happens at the exact moment of the dump.
595
It is also possible to set up a slave by dumping an existing slave of the master. To do this, use the
596
\fB\-\-dump\-slave\fR
600
\fB\-\-no\-autocommit\fR
604
statements for each dumped table within
611
\fB\-\-no\-create\-db\fR,
614
This option suppresses the
616
statements that are otherwise included in the output if the
619
\fB\-\-all\-databases\fR
623
\fB\-\-no\-create\-info\fR,
628
statements that re\-create each dumped table.
634
Do not write any table row information (that is, do not dump table contents). This is very useful if you want to dump only the
636
statement for the table.
639
\fB\-\-no\-set\-names\fR
641
This option is deprecated. Use
642
\fB\-\-skip\-set\-charset\fR. instead.
647
This option is shorthand; it is the same as specifying
648
\fB\-\-add\-drop\-table\fR
650
\fB\-\-create\-options\fR
651
\fB\-\-disable\-keys\fR
652
\fB\-\-extended\-insert\fR
653
\fB\-\-lock\-tables\fR
655
\fB\-\-set\-charset\fR. It should give you a fast dump operation and produce a dump file that can be reloaded into a MySQL server quickly.
657
\fIThe \fR\fI\fB\-\-opt\fR\fR\fI option is enabled by default. Use \fR\fI\fB\-\-skip\-opt\fR\fR\fI to disable it.\fR
658
See the discussion at the beginning of this section for information about selectively enabling or disabling certain of the options affected by
662
\fB\-\-order\-by\-primary\fR
664
Sorts each table's rows by its primary key, or by its first unique index, if such an index exists. This is useful when dumping a
666
table to be loaded into an
668
table, but will make the dump itself take considerably longer.
671
\fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,
672
\fB\-p[\fR\fB\fIpassword\fR\fR\fB]\fR
674
The password to use when connecting to the server. If you use the short option form (\fB\-p\fR), you
676
have a space between the option and the password. If you omit the
682
option on the command line, you are prompted for one.
684
Specifying a password on the command line should be considered insecure. See
685
Section\ 5.5.6.2, \(lqEnd\-User Guidelines for Password Security\(rq.
691
On Windows, connect to the server via a named pipe. This option applies only for connections to a local server, and only if the server supports named\-pipe connections.
694
\fB\-\-port=\fR\fB\fIport_num\fR\fR,
695
\fB\-P \fR\fB\fIport_num\fR\fR
697
The TCP/IP port number to use for the connection.
700
\fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR
702
The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the allowable values, see
703
Section\ 4.2.2, \(lqConnecting to the MySQL Server\(rq.
709
This option is useful for dumping large tables. It forces
711
to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out.
714
\fB\-\-quote\-names\fR,
717
Quote database, table, and column names within
721
SQL mode is enabled, names are quoted within
723
characters. This option is enabled by default. It can be disabled with
724
\fB\-\-skip\-quote\-names\fR, but this option should be given after any option such as
727
\fB\-\-quote\-names\fR.
734
statements rather than
739
\fB\-\-result\-file=\fR\fB\fIfile_name\fR\fR,
740
\fB\-r \fR\fB\fIfile_name\fR\fR
742
Direct output to a given file. This option should be used on Windows to prevent newline
744
characters from being converted to
746
carriage return/newline sequences. The result file is created and its contents overwritten, even if an error occurs while generating the dump. The previous contents are lost.
752
Dump stored routines (procedures and functions) from the dumped databases. Use of this option requires the
756
table. The output generated by using
762
statements to re\-create the routines. However, these statements do not include attributes such as the routine creation and modification timestamps. This means that when the routines are reloaded, they will be created with the timestamps equal to the reload time.
764
If you require routines to be re\-created with their original timestamp attributes, do not use
765
\fB\-\-routines\fR. Instead, dump and reload the contents of the
767
table directly, using a MySQL account that has appropriate privileges for the
772
\fB\-\-set\-charset\fR
775
SET NAMES \fIdefault_character_set\fR
776
to the output. This option is enabled by default. To suppress the
779
\fB\-\-skip\-set\-charset\fR.
782
\fB\-\-single\-transaction\fR
786
SQL statement before dumping data from the server. It is useful only with transactional tables such as
787
InnoDB, because then it dumps the consistent state of the database at the time when
789
was issued without blocking any applications.
791
When using this option, you should keep in mind that only
795
tables are dumped in a consistent state. For example, any
799
tables dumped while using this option may still change state.
802
\fB\-\-single\-transaction\fR
803
dump is in process, to ensure a valid dump file (correct table contents and binary log position), no other connection should use the following statements:
807
TRUNCATE TABLE. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause the
811
to retrieve the table contents to obtain incorrect contents or fail.
814
\fB\-\-single\-transaction\fR
816
\fB\-\-lock\-tables\fR
817
option are mutually exclusive, because
819
causes any pending transactions to be committed implicitly.
821
To dump large tables, you should combine this option with
825
\fB\-\-skip\-comments\fR
827
See the description for the
834
See the description for the
839
\fB\-\-socket=\fR\fB\fIpath\fR\fR,
840
\fB\-S \fR\fB\fIpath\fR\fR
843
localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.
848
Options that begin with
850
specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See
851
Section\ 5.5.7.3, \(lqSSL Command Options\(rq.
854
\fB\-\-tab=\fR\fB\fIpath\fR\fR,
855
\fB\-T \fR\fB\fIpath\fR\fR
857
Produce tab\-separated data files. For each dumped table,
860
\fI\fItbl_name\fR\fR\fI.sql\fR
861
file that contains the
863
statement that creates the table, and a
864
\fI\fItbl_name\fR\fR\fI.txt\fR
865
file that contains its data. The option value is the directory in which to write the files.
869
data files are formatted using tab characters between column values and a newline at the end of each line. The format can be specified explicitly using the
870
\fB\-\-fields\-\fR\fB\fIxxx\fR\fR
872
\fB\-\-lines\-terminated\-by\fR
875
Column values are dumped using the
877
character set and the
878
\fB\-\-default\-character\-set\fR
879
option is ignored. In effect, there is no character set conversion. If a table contains columns in several character sets, the output data file will as well and you may not be able to reload the file correctly.
882
.nr an-no-space-flag 1
886
This option should be used only when
888
is run on the same machine as the
890
server. You must have the
892
privilege, and the server must have permission to write files in the directory that you specify.
903
regards all name arguments following the option as table names.
908
Dump triggers for each dumped table. This option is enabled by default; disable it with
909
\fB\-\-skip\-triggers\fR.
916
columns to be dumped and reloaded between servers in different time zones.
918
sets its connection time zone to UTC and adds
919
SET TIME_ZONE='+00:00'
920
to the dump file. Without this option,
922
columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change.
924
also protects against changes due to daylight saving time.
926
is enabled by default. To disable it, use
927
\fB\-\-skip\-tz\-utc\fR.
930
\fB\-\-user=\fR\fB\fIuser_name\fR\fR,
931
\fB\-u \fR\fB\fIuser_name\fR\fR
933
The MySQL user name to use when connecting to the server.
939
Verbose mode. Print more information about what the program does.
945
Display version information and exit.
948
\fB\-\-where='\fR\fB\fIwhere_condition\fR\fR\fB'\fR,
949
\fB\-w '\fR\fB\fIwhere_condition\fR\fR\fB'\fR
951
Dump only rows selected by the given
953
condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter.
959
\-\-where="user='jimf'"
969
Write dump output as well\-formed XML.
971
\fBNULL\fR\fB, \fR\fB'NULL'\fR\fB, and Empty Values\fR: For some column named
972
\fIcolumn_name\fR, the
974
value, an empty string, and the string value
976
are distinguished from one another in the output generated by this option as follows.
986
\fBXML Representation\fR:
989
NULL (\fIunknown value\fR)
991
<field name="\fIcolumn_name\fR"
995
\'' (\fIempty string\fR)
998
name="\fIcolumn_name\fR"></field>
1001
\'NULL' (\fIstring value\fR)
1004
name="\fIcolumn_name\fR">NULL</field>
1010
client when run using the
1012
option also follows these rules. (See
1013
the section called \(lq\fBMYSQL\fR OPTIONS\(rq.)
1017
includes the XML namespace, as shown here:
1021
shell> \fBmysqldump \-\-xml \-u root world City\fR
1022
<?xml version="1.0"?>
1023
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema\-instance">
1024
<database name="world">
1025
<table_structure name="City">
1026
<field Field="ID" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
1027
<field Field="Name" Type="char(35)" Null="NO" Key="" Default="" Extra="" />
1028
<field Field="CountryCode" Type="char(3)" Null="NO" Key="" Default="" Extra="" />
1029
<field Field="District" Type="char(20)" Null="NO" Key="" Default="" Extra="" />
1030
<field Field="Population" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
1031
<key Table="City" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID" Collation="A" Cardinality="4079"
1032
Null="" Index_type="BTREE" Comment="" />
1033
<options Name="City" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="4079" Avg_row_length="67" Data_length="27329
1034
3" Max_data_length="18858823439613951" Index_length="43008" Data_free="0" Auto_increment="4080" Create_time="2007\-03\-31 01:47:01" Updat
1035
e_time="2007\-03\-31 01:47:02" Collation="latin1_swedish_ci" Create_options="" Comment="" />
1037
<table_data name="City">
1039
<field name="ID">1</field>
1040
<field name="Name">Kabul</field>
1041
<field name="CountryCode">AFG</field>
1042
<field name="District">Kabol</field>
1043
<field name="Population">1780000</field>
1047
<field name="ID">4079</field>
1048
<field name="Name">Rafah</field>
1049
<field name="CountryCode">PSE</field>
1050
<field name="District">Rafah</field>
1051
<field name="Population">92020</field>
1062
You can also set the following variables by using
1063
\fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR
1069
The maximum size of the buffer for client/server communication. The maximum is 1GB.
1074
The initial size of the buffer for client/server communication. When creating multiple\-row\-insert statements (as with option
1075
\fB\-\-extended\-insert\fR
1081
length. If you increase this variable, you should also ensure that the
1083
variable in the MySQL server is at least this large.
1087
The most common use of
1089
is probably for making a backup of an entire database:
1093
shell> \fBmysqldump \fR\fB\fIdb_name\fR\fR\fB > \fR\fB\fIbackup\-file.sql\fR\fR
1097
You can read the dump file back into the server like this:
1101
shell> \fBmysql \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fIbackup\-file.sql\fR\fR
1109
shell> \fBmysql \-e "source \fR\fB\fI/path\-to\-backup/backup\-file.sql\fR\fR\fB" \fR\fB\fIdb_name\fR\fR
1114
is also very useful for populating databases by copying data from one MySQL server to another:
1118
shell> \fBmysqldump \-\-opt \fR\fB\fIdb_name\fR\fR\fB | mysql \-\-host=\fR\fB\fIremote_host\fR\fR\fB \-C \fR\fB\fIdb_name\fR\fR
1122
It is possible to dump several databases with one command:
1126
shell> \fBmysqldump \-\-databases \fR\fB\fIdb_name1\fR\fR\fB [\fR\fB\fIdb_name2\fR\fR\fB ...] > my_databases.sql\fR
1130
To dump all databases, use the
1131
\fB\-\-all\-databases\fR
1136
shell> \fBmysqldump \-\-all\-databases > all_databases.sql\fR
1144
provides a way of making an online backup:
1148
shell> \fBmysqldump \-\-all\-databases \-\-single\-transaction > all_databases.sql\fR
1152
This backup acquires a global read lock on all tables (using
1153
FLUSH TABLES WITH READ LOCK) at the beginning of the dump. As soon as this lock has been acquired, the binary log coordinates are read and the lock is released. If long updating statements are running when the
1155
statement is issued, the MySQL server may get stalled until those statements finish. After that, the dump becomes lock\-free and does not disturb reads and writes on the tables. If the update statements that the MySQL server receives are short (in terms of execution time), the initial lock period should not be noticeable, even with many updates.
1157
For point\-in\-time recovery (also known as
1158
\(lqroll\-forward,\(rq
1159
when you need to restore an old backup and replay the changes that happened since that backup), it is often useful to rotate the binary log (see
1160
Section\ 5.2.4, \(lqThe Binary Log\(rq) or at least know the binary log coordinates to which the dump corresponds:
1164
shell> \fBmysqldump \-\-all\-databases \-\-master\-data=2 > all_databases.sql\fR
1172
shell> \fBmysqldump \-\-all\-databases \-\-flush\-logs \-\-master\-data=2\fR
1173
\fB> all_databases.sql\fR
1178
\fB\-\-master\-data\fR
1180
\fB\-\-single\-transaction\fR
1181
options can be used simultaneously, which provides a convenient way to make an online backup suitable for point\-in\-time recovery if tables are stored using the
1185
For more information on making backups, see
1186
Section\ 6.1, \(lqDatabase Backups\(rq, and
1187
Section\ 6.2, \(lqExample Backup and Recovery Strategy\(rq.
1189
If you encounter problems backing up views, please read the section that covers restrictions on views which describes a workaround for backing up views when this fails due to insufficient privileges. See
1190
Section\ D.5, \(lqRestrictions on Views\(rq.
1193
Copyright 2007\-2008 MySQL AB, 2009 Sun Microsystems, Inc.
1195
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
1197
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1199
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110\-1301 USA or see http://www.gnu.org/licenses/.
1201
For more information, please refer to the MySQL Reference Manual,
1202
which may already be installed locally and which is also available
1203
online at http://dev.mysql.com/doc/.
1205
Sun Microsystems, Inc. (http://www.mysql.com/).