2009-09-16 14:03:18 +02:00
'\" t
2009-05-25 11:59:47 +02:00
. \" Title: \fBmysqldump\fR
2009-09-16 14:03:18 +02:00
. \" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
. \" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
2010-04-28 15:06:11 +02:00
. \" Date: 04/06/2010
2009-05-25 11:59:47 +02:00
. \" Manual: MySQL Database System
. \" Source: MySQL 5.1
2009-09-16 14:03:18 +02:00
. \" Language: English
2009-05-25 11:59:47 +02:00
. \"
2010-04-28 15:06:11 +02:00
.TH "\FBMYSQLDUMP\FR" "1" "04/06/2010" "MySQL 5\&.1" "MySQL Database System"
2009-09-16 14:03:18 +02:00
. \" -----------------------------------------------------------------
. \" * set default formatting
. \" -----------------------------------------------------------------
2009-05-25 11:59:47 +02:00
. \" disable hyphenation
.nh
. \" disable justification (adjust text to left margin only)
.ad l
2009-09-16 14:03:18 +02:00
. \" -----------------------------------------------------------------
. \" * MAIN CONTENT STARTS HERE *
. \" -----------------------------------------------------------------
. \" mysqldump
. \" dumping: databases and tables
. \" backups: databases and tables
. \" databases: dumping
. \" tables: dumping
2009-05-25 11:59:47 +02:00
.SH "NAME"
mysqldump \- a database backup program
.SH "SYNOPSIS"
2009-09-16 14:03:18 +02:00
.HP \w '\fBmysqldump\ [\fR\fB\fIoptions\fR\fR\fB]\ [\fR\fB\fIdb_name\fR\fR\fB\ [\fR\fB\fItbl_name\fR\fR\fB\ \& .\&.\&.]]\fR\ 'u
\fB mysqldump [\fR \fB \fI options\fR \fR \fB ] [\fR \fB \fI db_name\fR \fR \fB [\fR \fB \fI tbl_name\fR \fR \fB \& .\& .\& .]]\fR
2009-05-25 11:59:47 +02:00
.SH "DESCRIPTION"
.PP
The
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
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,
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
can also be used to generate files in CSV, other delimited text, or XML format\& .
2009-05-25 11:59:47 +02:00
.PP
If you are doing a backup on the server and your tables all are
MyISAM
tables, consider using the
\fB mysqlhotcopy\fR
2009-09-16 14:03:18 +02:00
instead because it can accomplish faster backups and faster restores\& . See
\fB mysqlhotcopy\fR (1)\& .
2009-05-25 11:59:47 +02:00
.PP
There are three general ways to invoke
\fB mysqldump\fR :
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2010-04-28 15:06:11 +02:00
shell> \fB mysqldump [\fR \fB \fI options\fR \fR \fB ] \fR \fB \fI db_name\fR \fR \fB [\fR \fB \fI tbl_name\fR \fR \fB \& .\& .\& .]\fR
shell> \fB mysqldump [\fR \fB \fI options\fR \fR \fB ] \- \- databases \fR \fB \fI db_name\fR \fR \fB \& .\& .\& .\fR
2009-05-25 11:59:47 +02:00
shell> \fB mysqldump [\fR \fB \fI options\fR \fR \fB ] \- \- all\- databases\fR
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
If you do not name any tables following
\fI db_name\fR
or if you use the
\fB \- \- databases\fR
or
\fB \- \- all\- databases\fR
2009-09-16 14:03:18 +02:00
option, entire databases are dumped\& .
2009-05-25 11:59:47 +02:00
.PP
\fB mysqldump\fR
does not dump the
INFORMATION_SCHEMA
2010-04-28 15:06:11 +02:00
database by default\& . As of MySQL 5\& .1\& .38,
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2010-04-28 15:06:11 +02:00
dumps
INFORMATION_SCHEMA
if you name it explicitly on the command line, although currently you must also use the
\fB \- \- skip\- lock\- tables\fR
option\& . Before 5\& .1\& .38,
\fB mysqldump\fR
silently ignores
INFORMATION_SCHEMA
even if you name it explicitly on the command line\& .
2009-05-25 11:59:47 +02:00
.PP
2010-04-28 15:06:11 +02:00
To see a list of the options your version of
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
supports, execute
2009-09-16 14:03:18 +02:00
\fB mysqldump \- \- help\fR \& .
2009-05-25 11:59:47 +02:00
.PP
Some
\fB mysqldump\fR
2010-04-28 15:06:11 +02:00
options are shorthand for groups of other options:
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
Use of
2009-05-25 11:59:47 +02:00
\fB \- \- opt\fR
is the same as specifying
2010-04-28 15:06:11 +02:00
\fB \- \- add\- drop\- table\fR ,
\fB \- \- add\- locks\fR ,
\fB \- \- create\- options\fR ,
\fB \- \- disable\- keys\fR ,
\fB \- \- extended\- insert\fR ,
\fB \- \- lock\- tables\fR ,
\fB \- \- quick\fR , and
\fB \- \- set\- charset\fR \& . All of the options that
2009-05-25 11:59:47 +02:00
\fB \- \- opt\fR
stands for also are on by default because
\fB \- \- opt\fR
2009-09-16 14:03:18 +02:00
is on by default\& .
2010-04-28 15:06:11 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
Use of
\fB \- \- compact\fR
is the same as specifying
\fB \- \- skip\- add\- drop\- table\fR ,
\fB \- \- skip\- add\- locks\fR ,
\fB \- \- skip\- comments\fR ,
\fB \- \- skip\- disable\- keys\fR , and
\fB \- \- skip\- set\- charset\fR
options\& .
.RE
2009-05-25 11:59:47 +02:00
.PP
To reverse the effect of a group option, uses its
\fB \- \- skip\- \fR \fB \fI xxx\fR \fR
form (\fB \- \- skip\- opt\fR
or
2009-09-16 14:03:18 +02:00
\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:
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
2009-05-25 11:59:47 +02:00
To select the effect of
\fB \- \- opt\fR
except for some features, use the
\fB \- \- skip\fR
2010-04-28 15:06:11 +02:00
option for each feature\& . To disable extended inserts and memory buffering, use
2009-05-25 11:59:47 +02:00
\fB \- \- opt\fR
\fB \- \- skip\- extended\- insert\fR
2010-04-28 15:06:11 +02:00
\fB \- \- skip\- quick\fR \& . (Actually,
2009-05-25 11:59:47 +02:00
\fB \- \- skip\- extended\- insert\fR
\fB \- \- skip\- quick\fR
is sufficient because
\fB \- \- opt\fR
2009-09-16 14:03:18 +02:00
is on by default\& .)
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
2009-05-25 11:59:47 +02:00
To reverse
\fB \- \- opt\fR
for all features except index disabling and table locking, use
\fB \- \- skip\- opt\fR
\fB \- \- disable\- keys\fR
2009-09-16 14:03:18 +02:00
\fB \- \- lock\- tables\fR \& .
2009-05-25 11:59:47 +02:00
.RE
.PP
2009-09-16 14:03:18 +02:00
When you selectively enable or disable the effect of a group option, order is important because options are processed first to last\& . For example,
2009-05-25 11:59:47 +02:00
\fB \- \- disable\- keys\fR
\fB \- \- lock\- tables\fR
\fB \- \- skip\- opt\fR
would not have the intended effect; it is the same as
\fB \- \- skip\- opt\fR
2009-09-16 14:03:18 +02:00
by itself\& .
2009-05-25 11:59:47 +02:00
.PP
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
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
2009-05-25 11:59:47 +02:00
\fB \- \- quick\fR
option (or
\fB \- \- opt\fR , which enables
2009-09-16 14:03:18 +02:00
\fB \- \- quick\fR )\& . The
2009-05-25 11:59:47 +02:00
\fB \- \- opt\fR
option (and hence
2010-04-28 15:06:11 +02:00
\fB \- \- quick\fR ) is enabled by default, so to enable memory buffering, use
2009-09-16 14:03:18 +02:00
\fB \- \- skip\- quick\fR \& .
2009-05-25 11:59:47 +02:00
.PP
If you are using a recent version of
\fB mysqldump\fR
to generate a dump to be reloaded into a very old MySQL server, you should not use the
\fB \- \- opt\fR
or
\fB \- \- extended\- insert\fR
2009-09-16 14:03:18 +02:00
option\& . Use
2009-05-25 11:59:47 +02:00
\fB \- \- skip\- opt\fR
2009-09-16 14:03:18 +02:00
instead\& .
.if n \{ \
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
. \}
.RS 4
2009-05-25 11:59:47 +02:00
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
2009-09-16 14:03:18 +02:00
.ps +1
2009-05-25 11:59:47 +02:00
\fB Note\fR
2009-09-16 14:03:18 +02:00
.ps -1
.br
2009-05-25 11:59:47 +02:00
.PP
\fB mysqldump\fR
2010-04-28 15:06:11 +02:00
from MySQL 5\& .1\& .21 cannot be used to create dumps from MySQL server 5\& .1\& .20 and older\& . This issue is fixed in MySQL 5\& .1\& .22\& . (\m[blue]\fBBug#30123\fR\m[]\&\s-2\u[1] \d \s +2)
2009-09-16 14:03:18 +02:00
.sp .5v
.RE
2009-05-25 11:59:47 +02:00
.PP
\fB mysqldump\fR
2010-04-28 15:06:11 +02:00
supports the following options, which can be specified on the command line or in the
[mysqldump]
and
[client]
option file groups\& .
\fB mysqldump\fR
also supports the options for processing option files described at
2009-09-16 14:03:18 +02:00
Section\ \& 4.2.3.3.1, \(lq Command-Line Options that Affect Option-File Handling\(rq \& .
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: help option
. \" help option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- help\fR ,
\fB \- ?\fR
.sp
2009-09-16 14:03:18 +02:00
Display a help message and exit\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: add-drop-database option
. \" add-drop-database option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- add\- drop\- database\fR
.sp
Add a
DROP DATABASE
statement before each
CREATE DATABASE
2010-04-28 15:06:11 +02:00
statement\& . This option is typically used in conjunction with the
\fB \- \- all\- databases\fR
or
\fB \- \- databases\fR
option because no
CREATE DATABASE
statements are written unless one of those options is specified\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: add-drop-table option
. \" add-drop-table option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- add\- drop\- table\fR
.sp
Add a
DROP TABLE
statement before each
CREATE TABLE
2009-09-16 14:03:18 +02:00
statement\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: add-locks option
. \" add-locks option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- add\- locks\fR
.sp
Surround each table dump with
LOCK TABLES
and
UNLOCK TABLES
2009-09-16 14:03:18 +02:00
statements\& . This results in faster inserts when the dump file is reloaded\& . See
Section\ \& 7.2.21, \(lq Speed of INSERT Statements\(rq \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: all-databases option
. \" all-databases option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- all\- databases\fR ,
\fB \- A\fR
.sp
2009-09-16 14:03:18 +02:00
Dump all tables in all databases\& . This is the same as using the
2009-05-25 11:59:47 +02:00
\fB \- \- databases\fR
2009-09-16 14:03:18 +02:00
option and naming all the databases on the command line\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: all-tablespaces option
. \" all-tablespaces option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- all\- tablespaces\fR ,
\fB \- Y\fR
.sp
Adds to a table dump all SQL statements needed to create any tablespaces used by an
NDBCLUSTER
2009-09-16 14:03:18 +02:00
table\& . This information is not otherwise included in the output from
\fB mysqldump\fR \& . This option is currently relevant only to MySQL Cluster tables\& .
.sp
This option was added in MySQL 5\& .1\& .6\& .
.RE
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: allow-keywords option
. \" allow-keywords option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- allow\- keywords\fR
.sp
2009-09-16 14:03:18 +02:00
Allow creation of column names that are keywords\& . This works by prefixing each column name with the table name\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: character-sets-dir option
. \" character-sets-dir option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- character\- sets\- dir=\fR \fB \fI path\fR \fR
.sp
2009-09-16 14:03:18 +02:00
The directory where character sets are installed\& . See
2010-04-28 15:06:11 +02:00
Section\ \& 9.5, \(lq Character Set Configuration\(rq \& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: comments option
. \" comments option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- comments\fR ,
\fB \- i\fR
.sp
2009-09-16 14:03:18 +02:00
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
\fB \- \- skip\- comments\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: compact option
. \" compact option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- compact\fR
.sp
2010-04-28 15:06:11 +02:00
Produce more compact output\& . This option enables the
2009-05-25 11:59:47 +02:00
\fB \- \- skip\- add\- drop\- table\fR ,
\fB \- \- skip\- add\- locks\fR ,
\fB \- \- skip\- comments\fR ,
\fB \- \- skip\- disable\- keys\fR , and
\fB \- \- skip\- set\- charset\fR
2009-09-16 14:03:18 +02:00
options\& .
.if n \{ \
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
. \}
.RS 4
2009-05-25 11:59:47 +02:00
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
2009-09-16 14:03:18 +02:00
.ps +1
2009-05-25 11:59:47 +02:00
\fB Note\fR
2009-09-16 14:03:18 +02:00
.ps -1
.br
2010-04-28 15:06:11 +02:00
Prior to MySQL 5\& .1\& .21, this option did not create valid SQL if the database dump contained views\& . The recreation of views requires the creation and removal of temporary tables and this option suppressed the removal of those temporary tables\& . As a workaround, use
2009-05-25 11:59:47 +02:00
\fB \- \- compact\fR
with the
\fB \- \- add\- drop\- table\fR
2009-09-16 14:03:18 +02:00
option and then manually adjust the dump file\& .
.sp .5v
.RE
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: compatible option
. \" compatible option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- compatible=\fR \fB \fI name\fR \fR
.sp
2009-09-16 14:03:18 +02:00
Produce output that is more compatible with other database systems or with older MySQL servers\& . The value of
2010-04-28 15:06:11 +02:00
\fI name\fR
2009-05-25 11:59:47 +02:00
can be
ansi,
mysql323,
mysql40,
postgresql,
oracle,
mssql,
db2,
maxdb,
no_key_options,
no_table_options, or
2009-09-16 14:03:18 +02:00
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
Section\ \& 5.1.8, \(lq Server SQL Modes\(rq \& .
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
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,
2009-05-25 11:59:47 +02:00
\fB \- \- compatible=oracle\fR
2009-09-16 14:03:18 +02:00
does not map data types to Oracle types or use Oracle comment syntax\& .
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
\fI This option requires a server version of 4\& .1\& .0 or higher\fR \& . With older servers, it does nothing\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: complete-insert option
. \" complete-insert option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- complete\- insert\fR ,
\fB \- c\fR
.sp
Use complete
INSERT
2009-09-16 14:03:18 +02:00
statements that include column names\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: compress option
. \" compress option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- compress\fR ,
\fB \- C\fR
.sp
2009-09-16 14:03:18 +02:00
Compress all information sent between the client and the server if both support compression\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: create-options option
. \" create-options option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- create\- options\fR
.sp
Include all MySQL\- specific table options in the
CREATE TABLE
2009-09-16 14:03:18 +02:00
statements\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: databases option
. \" databases option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- databases\fR ,
\fB \- B\fR
.sp
2009-09-16 14:03:18 +02:00
Dump several databases\& . Normally,
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
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\& .
2009-05-25 11:59:47 +02:00
CREATE DATABASE
and
USE
2009-09-16 14:03:18 +02:00
statements are included in the output before each new database\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: debug option
. \" debug option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- debug[=\fR \fB \fI debug_options\fR \fR \fB ]\fR ,
\fB \- # [\fR \fB \fI debug_options\fR \fR \fB ]\fR
.sp
2009-09-16 14:03:18 +02:00
Write a debugging log\& . A typical
2009-05-25 11:59:47 +02:00
\fI debug_options\fR
2009-09-16 14:03:18 +02:00
string is
\' d:t:o,\fI file_name\fR \' \& . The default value is
\' d:t:o,/tmp/mysqldump\& .trace\' \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: debug-check option
. \" debug-check option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- debug\- check\fR
.sp
2009-09-16 14:03:18 +02:00
Print some debugging information when the program exits\& . This option was added in MySQL 5\& .1\& .21\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: debug-info option
. \" debug-info option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- debug\- info\fR
.sp
2009-09-16 14:03:18 +02:00
Print debugging information and memory and CPU usage statistics when the program exits\& . This option was added in MySQL 5\& .1\& .14\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: default-character-set option
. \" default-character-set option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- default\- character\- set=\fR \fB \fI charset_name\fR \fR
.sp
Use
\fI charset_name\fR
2009-09-16 14:03:18 +02:00
as the default character set\& . See
2010-04-28 15:06:11 +02:00
Section\ \& 9.5, \(lq Character Set Configuration\(rq \& . If no character set is specified,
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
uses
utf8, and earlier versions use
2009-09-16 14:03:18 +02:00
latin1\& .
2009-05-25 11:59:47 +02:00
.sp
2009-12-01 08:24:05 +01:00
Prior to MySQL 5\& .1\& .38, this option has no effect for output data files produced by using the
2009-05-25 11:59:47 +02:00
\fB \- \- tab\fR
2009-09-16 14:03:18 +02:00
option\& . See the description for that option\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: delayed-insert option
. \" delayed-insert option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- delayed\- insert\fR
.sp
Write
INSERT DELAYED
statements rather than
INSERT
2009-09-16 14:03:18 +02:00
statements\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: delete-master-logs option
. \" delete-master-logs option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- delete\- master\- logs\fR
.sp
2010-04-28 15:06:11 +02:00
On a master replication server, delete the binary logs by sending a
PURGE BINARY LOGS
statement to the server after performing the dump operation\& . This option automatically enables
2009-09-16 14:03:18 +02:00
\fB \- \- master\- data\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: disable-keys option
. \" disable-keys option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- disable\- keys\fR ,
\fB \- K\fR
.sp
For each table, surround the
INSERT
statements with
/*!40000 ALTER TABLE \fI tbl_name\fR DISABLE KEYS */;
and
/*!40000 ALTER TABLE \fI tbl_name\fR ENABLE KEYS */;
2009-09-16 14:03:18 +02:00
statements\& . This makes loading the dump file faster because the indexes are created after all rows are inserted\& . This option is effective only for nonunique indexes of
2009-05-25 11:59:47 +02:00
MyISAM
2009-09-16 14:03:18 +02:00
tables\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: dump-date option
. \" dump-date option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- dump\- date\fR
.sp
2010-04-28 15:06:11 +02:00
If the
\fB \- \- comments\fR
option is given,
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2010-04-28 15:06:11 +02:00
produces a comment at the end of the dump of the following form:
.sp
.if n \{ \
.RS 4
. \}
.nf
2009-05-25 11:59:47 +02:00
\- \- Dump completed on \fI DATE\fR
2010-04-28 15:06:11 +02:00
.fi
.if n \{ \
.RE
. \}
.sp
However, the date causes dump files taken at different times to appear to be different, even if the data are otherwise identical\& .
2009-05-25 11:59:47 +02:00
\fB \- \- dump\- date\fR
and
\fB \- \- skip\- dump\- date\fR
2009-09-16 14:03:18 +02:00
control whether the date is added to the comment\& . The default is
2009-05-25 11:59:47 +02:00
\fB \- \- dump\- date\fR
2009-09-16 14:03:18 +02:00
(include the date in the comment)\& .
2009-05-25 11:59:47 +02:00
\fB \- \- skip\- dump\- date\fR
2009-09-16 14:03:18 +02:00
suppresses date printing\& . This option was added in MySQL 5\& .1\& .23\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: events option
. \" events option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- events\fR ,
\fB \- E\fR
.sp
2010-04-28 15:06:11 +02:00
Include Event Scheduler events for the dumped databases in the output\& . This option was added in MySQL 5\& .1\& .8\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: extended-insert option
. \" extended-insert option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- extended\- insert\fR ,
\fB \- e\fR
.sp
Use multiple\- row
INSERT
syntax that include several
VALUES
2009-09-16 14:03:18 +02:00
lists\& . This results in a smaller dump file and speeds up inserts when the file is reloaded\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: fields-terminated-by option
. \" fields-terminated-by option: mysqldump
\fB \- \- fields\- terminated\- by=\& .\& .\& .\fR ,
. \" mysqldump: fields-enclosed-by option
. \" fields-enclosed-by option: mysqldump
\fB \- \- fields\- enclosed\- by=\& .\& .\& .\fR ,
. \" mysqldump: fields-optionally-enclosed-by option
. \" fields-optionally-enclosed-by option: mysqldump
\fB \- \- fields\- optionally\- enclosed\- by=\& .\& .\& .\fR ,
. \" mysqldump: fields-escaped-by option
. \" fields-escaped-by option: mysqldump
\fB \- \- fields\- escaped\- by=\& .\& .\& .\fR
2009-05-25 11:59:47 +02:00
.sp
These options are used with the
2010-04-28 15:06:11 +02:00
\fB \- \- tab\fR
option and have the same meaning as the corresponding
FIELDS
clauses for
2009-09-16 14:03:18 +02:00
LOAD DATA INFILE\& . See
Section\ \& 12.2.6, \(lq LOAD DATA INFILE Syntax\(rq \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: first-slave option
. \" first-slave option: mysqldump
2010-04-28 15:06:11 +02:00
\fB \- \- first\- slave\fR
2009-05-25 11:59:47 +02:00
.sp
2010-04-28 15:06:11 +02:00
Deprecated\& . Use
\fB \- \- lock\- all\- tables\fR
instead\& .
\fB \- \- first\- slave\fR
is removed in MySQL 5\& .5\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: flush-logs option
. \" flush-logs option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- flush\- logs\fR ,
\fB \- F\fR
.sp
2009-09-16 14:03:18 +02:00
Flush the MySQL server log files before starting the dump\& . This option requires the
2009-05-25 11:59:47 +02:00
RELOAD
2010-04-28 15:06:11 +02:00
privilege\& . If you use this option in combination with the
2009-05-25 11:59:47 +02:00
\fB \- \- all\- databases\fR
2010-04-28 15:06:11 +02:00
option, the logs are flushed
2009-09-16 14:03:18 +02:00
\fI for each database dumped\fR \& . The exception is when using
2009-05-25 11:59:47 +02:00
\fB \- \- lock\- all\- tables\fR
or
2009-09-16 14:03:18 +02:00
\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
2009-05-25 11:59:47 +02:00
\fB \- \- flush\- logs\fR
together with either
\fB \- \- lock\- all\- tables\fR
or
2009-09-16 14:03:18 +02:00
\fB \- \- master\- data\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: flush-privileges option
. \" flush-privileges option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- flush\- privileges\fR
.sp
2010-04-28 15:06:11 +02:00
Send a
2009-05-25 11:59:47 +02:00
FLUSH PRIVILEGES
2010-04-28 15:06:11 +02:00
statement to the server after dumping the
2009-05-25 11:59:47 +02:00
mysql
2009-09-16 14:03:18 +02:00
database\& . This option should be used any time the dump contains the
2009-05-25 11:59:47 +02:00
mysql
database and any other database that depends on the data in the
mysql
2009-09-16 14:03:18 +02:00
database for proper restoration\& . This option was added in MySQL 5\& .1\& .12\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: force option
. \" force option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- force\fR ,
\fB \- f\fR
.sp
2009-09-16 14:03:18 +02:00
Continue even if an SQL error occurs during a table dump\& .
2009-05-25 11:59:47 +02:00
.sp
One use for this option is to cause
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
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
2009-05-25 11:59:47 +02:00
\fB \- \- force\fR ,
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
exits with an error message\& . With
2009-05-25 11:59:47 +02:00
\fB \- \- force\fR ,
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
prints the error message, but it also writes an SQL comment containing the view definition to the dump output and continues executing\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: host option
. \" host option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- host=\fR \fB \fI host_name\fR \fR ,
\fB \- h \fR \fB \fI host_name\fR \fR
.sp
2009-09-16 14:03:18 +02:00
Dump data from the MySQL server on the given host\& . The default host is
localhost\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: hex-blob option
. \" hex-blob option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- hex\- blob\fR
.sp
Dump binary columns using hexadecimal notation (for example,
2009-09-16 14:03:18 +02:00
\' abc\'
2009-05-25 11:59:47 +02:00
becomes
2009-09-16 14:03:18 +02:00
0x616263)\& . The affected data types are
2009-05-25 11:59:47 +02:00
BINARY,
2010-04-28 15:06:11 +02:00
VARBINARY, the
BLOB
types, and
2009-09-16 14:03:18 +02:00
BIT\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: ignore-table option
. \" ignore-table option: mysqldump
\fB \- \- ignore\- table=\fR \fB \fI db_name\& .tbl_name\fR \fR
.sp
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\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: insert-ignore option
. \" insert-ignore option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- insert\- ignore\fR
.sp
Write
2010-04-28 15:06:11 +02:00
INSERT IGNORE
statements rather than
2009-05-25 11:59:47 +02:00
INSERT
2010-04-28 15:06:11 +02:00
statements\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: lines-terminated-by option
. \" lines-terminated-by option: mysqldump
\fB \- \- lines\- terminated\- by=\& .\& .\& .\fR
2009-05-25 11:59:47 +02:00
.sp
This option is used with the
2010-04-28 15:06:11 +02:00
\fB \- \- tab\fR
option and has the same meaning as the corresponding
LINES
clause for
2009-09-16 14:03:18 +02:00
LOAD DATA INFILE\& . See
Section\ \& 12.2.6, \(lq LOAD DATA INFILE Syntax\(rq \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: lock-all-tables option
. \" lock-all-tables option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- lock\- all\- tables\fR ,
\fB \- x\fR
.sp
2009-09-16 14:03:18 +02:00
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
2009-05-25 11:59:47 +02:00
\fB \- \- single\- transaction\fR
and
2009-09-16 14:03:18 +02:00
\fB \- \- lock\- tables\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: lock-tables option
. \" lock-tables option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- lock\- tables\fR ,
\fB \- l\fR
.sp
2010-04-28 15:06:11 +02:00
For each dumped database, lock all tables to be dumped before dumping them\& . The tables are locked with
2009-05-25 11:59:47 +02:00
READ LOCAL
to allow concurrent inserts in the case of
MyISAM
2009-09-16 14:03:18 +02:00
tables\& . For transactional tables such as
InnoDB,
2009-05-25 11:59:47 +02:00
\fB \- \- single\- transaction\fR
2010-04-28 15:06:11 +02:00
is a much better option than
\fB \- \- lock\- tables\fR
because it does not need to lock the tables at all\& .
2009-05-25 11:59:47 +02:00
.sp
2010-04-28 15:06:11 +02:00
Because
2009-05-25 11:59:47 +02:00
\fB \- \- lock\- tables\fR
2010-04-28 15:06:11 +02:00
locks tables for each database separately, this option does not guarantee that the tables in the dump file are logically consistent between databases\& . Tables in different databases may be dumped in completely different states\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: log-error option
. \" log-error option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- log\- error=\fR \fB \fI file_name\fR \fR
.sp
2010-04-28 15:06:11 +02:00
Log warnings and errors by appending them to the named file\& . The default is to do no logging\& . This option was added in MySQL 5\& .1\& .18\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: master-data option
. \" master-data option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- master\- data[=\fR \fB \fI value\fR \fR \fB ]\fR
.sp
2009-09-16 14:03:18 +02:00
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
2009-05-25 11:59:47 +02:00
CHANGE MASTER TO
2010-04-28 15:06:11 +02:00
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 after you load the dump file into the slave\& .
2009-05-25 11:59:47 +02:00
.sp
If the option value is 2, the
CHANGE MASTER TO
2010-04-28 15:06:11 +02:00
statement is written as an SQL comment, and thus is informative only; it has no effect when the dump file is reloaded\& . If the option value is 1, the statement is not written as a comment and takes effect when the dump file is reloaded\& . If no option value is specified, the default value is 1\& .
2009-05-25 11:59:47 +02:00
.sp
This option requires the
RELOAD
2009-09-16 14:03:18 +02:00
privilege and the binary log must be enabled\& .
2009-05-25 11:59:47 +02:00
.sp
The
\fB \- \- master\- data\fR
option automatically turns off
2009-09-16 14:03:18 +02:00
\fB \- \- lock\- tables\fR \& . It also turns on
2009-05-25 11:59:47 +02:00
\fB \- \- lock\- all\- tables\fR , unless
\fB \- \- single\- transaction\fR
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
2009-09-16 14:03:18 +02:00
\fB \- \- single\- transaction\fR )\& . In all cases, any action on logs happens at the exact moment of the dump\& .
.sp
It is also possible to set up a slave by dumping an existing slave of the master\& . To do this, use the following procedure on the existing slave:
.sp
.RS 4
.ie n \{ \
\h '-04' 1.\h '+01'\c
. \}
.el \{ \
.sp -1
.IP " 1." 4 .2
. \}
Stop the slave\' s SQL thread and get its current status:
.sp
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
mysql> \fB STOP SLAVE SQL_THREAD;\fR
mysql> \fB SHOW SLAVE STATUS;\fR
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
.RE
. \}
.RE
.sp
.RS 4
.ie n \{ \
\h '-04' 2.\h '+01'\c
. \}
.el \{ \
.sp -1
.IP " 2." 4 .2
. \}
2010-04-28 15:06:11 +02:00
From the output of the
SHOW SLAVE STATUS
statement, the binary log coordinates of the master server from which the new slave should start replicating are the values of the
Relay_Master_Log_File
and
Exec_Master_Log_Pos
fields\& . Denote those values as
\fI file_name\fR
and
\fI file_pos\fR \& .
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
.sp
.RS 4
.ie n \{ \
\h '-04' 3.\h '+01'\c
. \}
.el \{ \
.sp -1
.IP " 3." 4 .2
. \}
2009-05-25 11:59:47 +02:00
Dump the slave server:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
shell> \fB mysqldump \- \- master\- data=2 \- \- all\- databases > dumpfile\fR
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
.RE
. \}
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
.sp
.RS 4
.ie n \{ \
\h '-04' 4.\h '+01'\c
. \}
.el \{ \
.sp -1
.IP " 4." 4 .2
. \}
2009-05-25 11:59:47 +02:00
Restart the slave:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
mysql> \fB START SLAVE;\fR
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
.RE
. \}
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
.sp
.RS 4
.ie n \{ \
\h '-04' 5.\h '+01'\c
. \}
.el \{ \
.sp -1
.IP " 5." 4 .2
. \}
2010-04-28 15:06:11 +02:00
On the new slave, load the dump file:
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
shell> \fB mysql < dumpfile\fR
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
.RE
.sp
.RS 4
.ie n \{ \
\h '-04' 6.\h '+01'\c
. \}
.el \{ \
.sp -1
.IP " 6." 4 .2
. \}
2009-05-25 11:59:47 +02:00
On the new slave, set the replication coordinates to those of the master server obtained earlier:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
mysql> \fB CHANGE MASTER TO\fR
2010-04-28 15:06:11 +02:00
\- > \fB MASTER_LOG_FILE = \' \fR \fB \fI file_name\fR \fR \fB \' , MASTER_LOG_POS = \fR \fB \fI file_pos\fR \fR \fB ;\fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
.sp
2009-05-25 11:59:47 +02:00
The
CHANGE MASTER TO
statement might also need other parameters, such as
MASTER_HOST
2009-09-16 14:03:18 +02:00
to point the slave to the correct master server host\& . Add any such parameters as necessary\& .
.RE
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: no-autocommit option
. \" no-autocommit option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- no\- autocommit\fR
.sp
Enclose the
INSERT
statements for each dumped table within
SET autocommit = 0
and
COMMIT
2009-09-16 14:03:18 +02:00
statements\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: no-create-db option
. \" no-create-db option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- no\- create\- db\fR ,
\fB \- n\fR
.sp
This option suppresses the
CREATE DATABASE
statements that are otherwise included in the output if the
\fB \- \- databases\fR
or
\fB \- \- all\- databases\fR
2009-09-16 14:03:18 +02:00
option is given\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: no-create-info option
. \" no-create-info option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- no\- create\- info\fR ,
\fB \- t\fR
.sp
Do not write
CREATE TABLE
2009-09-16 14:03:18 +02:00
statements that re\- create each dumped table\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: no-data option
. \" no-data option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- no\- data\fR ,
\fB \- d\fR
.sp
2010-04-28 15:06:11 +02:00
Do not write any table row information (that is, do not dump table contents)\& . This is useful if you want to dump only the
2009-05-25 11:59:47 +02:00
CREATE TABLE
2010-04-28 15:06:11 +02:00
statement for the table (for example, to create an empty copy of the table by loading the dump file)\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: no-set-names option
. \" no-set-names option: mysqldump
2010-04-28 15:06:11 +02:00
\fB \- \- no\- set\- names\fR ,
\fB \- N\fR
2009-09-16 14:03:18 +02:00
.sp
2010-04-28 15:06:11 +02:00
This has the same effect as
\fB \- \- skip\- set\- charset\fR \& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: opt option
. \" opt option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- opt\fR
.sp
2010-04-28 15:06:11 +02:00
This option is shorthand\& . It is the same as specifying
2009-05-25 11:59:47 +02:00
\fB \- \- add\- drop\- table\fR
\fB \- \- add\- locks\fR
\fB \- \- create\- options\fR
\fB \- \- disable\- keys\fR
\fB \- \- extended\- insert\fR
\fB \- \- lock\- tables\fR
\fB \- \- quick\fR
2009-09-16 14:03:18 +02:00
\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\& .
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
\fI The \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
2010-04-28 15:06:11 +02:00
See the discussion at the beginning of this section for information about selectively enabling or disabling a subset of the options affected by
2009-09-16 14:03:18 +02:00
\fB \- \- opt\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: order-by-primary option
. \" order-by-primary option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- order\- by\- primary\fR
.sp
2010-04-28 15:06:11 +02:00
Dump each table\' s rows sorted by its primary key, or by its first unique index, if such an index exists\& . This is useful when dumping a
2009-05-25 11:59:47 +02:00
MyISAM
table to be loaded into an
InnoDB
2010-04-28 15:06:11 +02:00
table, but will make the dump operation take considerably longer\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: password option
. \" password option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- password[=\fR \fB \fI password\fR \fR \fB ]\fR ,
\fB \- p[\fR \fB \fI password\fR \fR \fB ]\fR
.sp
2009-09-16 14:03:18 +02:00
The password to use when connecting to the server\& . If you use the short option form (\fB \- p\fR ), you
2009-05-25 11:59:47 +02:00
\fI cannot\fR
2009-09-16 14:03:18 +02:00
have a space between the option and the password\& . If you omit the
2009-05-25 11:59:47 +02:00
\fI password\fR
value following the
\fB \- \- password\fR
or
\fB \- p\fR
2010-04-28 15:06:11 +02:00
option on the command line,
\fB mysqldump\fR
prompts for one\& .
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
Specifying a password on the command line should be considered insecure\& . See
2010-04-28 15:06:11 +02:00
Section\ \& 5.3.2.2, \(lq End-User Guidelines for Password Security\(rq \& . You can use an option file to avoid giving the password on the command line\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: pipe option
. \" pipe option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- pipe\fR ,
\fB \- W\fR
.sp
2010-04-28 15:06:11 +02:00
On Windows, connect to the server via a named pipe\& . This option applies only if the server supports named\- pipe connections\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: port option
. \" port option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- port=\fR \fB \fI port_num\fR \fR ,
\fB \- P \fR \fB \fI port_num\fR \fR
.sp
2009-09-16 14:03:18 +02:00
The TCP/IP port number to use for the connection\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: protocol option
. \" protocol option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- protocol={TCP|SOCKET|PIPE|MEMORY}\fR
.sp
2009-09-16 14:03:18 +02:00
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
Section\ \& 4.2.2, \(lq Connecting to the MySQL Server\(rq \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: quick option
. \" quick option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- quick\fR ,
\fB \- q\fR
.sp
2009-09-16 14:03:18 +02:00
This option is useful for dumping large tables\& . It forces
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
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\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: quote-names option
. \" quote-names option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- quote\- names\fR ,
\fB \- Q\fR
.sp
2010-04-28 15:06:11 +02:00
Quote identifiers (such as database, table, and column names) within
2009-05-25 11:59:47 +02:00
\(lq `\(rq
2009-09-16 14:03:18 +02:00
characters\& . If the
2009-05-25 11:59:47 +02:00
ANSI_QUOTES
2010-04-28 15:06:11 +02:00
SQL mode is enabled, identifiers are quoted within
2009-05-25 11:59:47 +02:00
\(lq "\(rq
2009-09-16 14:03:18 +02:00
characters\& . This option is enabled by default\& . It can be disabled with
2009-05-25 11:59:47 +02:00
\fB \- \- skip\- quote\- names\fR , but this option should be given after any option such as
\fB \- \- compatible\fR
that may enable
2009-09-16 14:03:18 +02:00
\fB \- \- quote\- names\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: replace option
. \" replace option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- replace\fR
.sp
Write
REPLACE
statements rather than
INSERT
2010-04-28 15:06:11 +02:00
statements\& . This option was added in MySQL 5\& .1\& .3\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: result-file option
. \" result-file option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- result\- file=\fR \fB \fI file_name\fR \fR ,
\fB \- r \fR \fB \fI file_name\fR \fR
.sp
2009-09-16 14:03:18 +02:00
Direct output to a given file\& . This option should be used on Windows to prevent newline
\(lq \e n\(rq
2009-05-25 11:59:47 +02:00
characters from being converted to
2009-09-16 14:03:18 +02:00
\(lq \e r\e n\(rq
2010-04-28 15:06:11 +02:00
carriage return/newline sequences\& . The result file is created and its previous contents overwritten, even if an error occurs while generating the dump\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: routines option
. \" routines option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- routines\fR ,
\fB \- R\fR
.sp
2010-04-28 15:06:11 +02:00
Included stored routines (procedures and functions) for the dumped databases in the output\& . Use of this option requires the
2009-05-25 11:59:47 +02:00
SELECT
privilege for the
2009-09-16 14:03:18 +02:00
mysql\& .proc
table\& . The output generated by using
2009-05-25 11:59:47 +02:00
\fB \- \- routines\fR
contains
CREATE PROCEDURE
and
CREATE FUNCTION
2009-09-16 14:03:18 +02:00
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\& .
2009-05-25 11:59:47 +02:00
.sp
If you require routines to be re\- created with their original timestamp attributes, do not use
2009-09-16 14:03:18 +02:00
\fB \- \- routines\fR \& . Instead, dump and reload the contents of the
mysql\& .proc
2009-05-25 11:59:47 +02:00
table directly, using a MySQL account that has appropriate privileges for the
mysql
2009-09-16 14:03:18 +02:00
database\& .
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
This option was added in MySQL 5\& .1\& .2\& . Before that, stored routines are not dumped\& . Routine
2009-05-25 11:59:47 +02:00
DEFINER
2009-09-16 14:03:18 +02:00
values are not dumped until MySQL 5\& .1\& .8\& . This means that before 5\& .1\& .8, when routines are reloaded, they will be created with the definer set to the reloading user\& . If you require routines to be re\- created with their original definer, dump and load the contents of the
mysql\& .proc
table directly as described earlier\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: set-charset option
. \" set-charset option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- set\- charset\fR
.sp
Add
SET NAMES \fI default_character_set\fR
2009-09-16 14:03:18 +02:00
to the output\& . This option is enabled by default\& . To suppress the
2009-05-25 11:59:47 +02:00
SET NAMES
statement, use
2009-09-16 14:03:18 +02:00
\fB \- \- skip\- set\- charset\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: single-transaction option
. \" single-transaction option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- single\- transaction\fR
.sp
2010-04-28 15:06:11 +02:00
This option sends a
START TRANSACTION
SQL statement to the server before dumping data\& . It is useful only with transactional tables such as
2009-05-25 11:59:47 +02:00
InnoDB, because then it dumps the consistent state of the database at the time when
BEGIN
2009-09-16 14:03:18 +02:00
was issued without blocking any applications\& .
2009-05-25 11:59:47 +02:00
.sp
When using this option, you should keep in mind that only
InnoDB
2009-09-16 14:03:18 +02:00
tables are dumped in a consistent state\& . For example, any
2009-05-25 11:59:47 +02:00
MyISAM
or
MEMORY
2009-09-16 14:03:18 +02:00
tables dumped while using this option may still change state\& .
2009-05-25 11:59:47 +02:00
.sp
While a
\fB \- \- single\- transaction\fR
2010-04-28 15:06:11 +02:00
dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates), no other connection should use the following statements:
2009-05-25 11:59:47 +02:00
ALTER TABLE,
2010-04-28 15:06:11 +02:00
CREATE TABLE,
2009-05-25 11:59:47 +02:00
DROP TABLE,
RENAME TABLE,
2009-09-16 14:03:18 +02:00
TRUNCATE TABLE\& . A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause the
2009-05-25 11:59:47 +02:00
SELECT
2010-04-28 15:06:11 +02:00
that is performed by
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
to retrieve the table contents to obtain incorrect contents or fail\& .
2009-05-25 11:59:47 +02:00
.sp
2010-04-28 15:06:11 +02:00
The
\fB \- \- single\- transaction\fR
option and the
\fB \- \- lock\- tables\fR
option are mutually exclusive because
LOCK TABLES
causes any pending transactions to be committed implicitly\& .
.sp
2009-05-25 11:59:47 +02:00
This option is not supported for MySQL Cluster tables; the results cannot be guaranteed to be consistent due to the fact that the
NDBCLUSTER
storage engine supports only the
READ_COMMITTED
2009-09-16 14:03:18 +02:00
transaction isolation level\& . You should always use
2009-05-25 11:59:47 +02:00
NDB
2009-09-16 14:03:18 +02:00
backup and restore instead\& .
2009-05-25 11:59:47 +02:00
.sp
2010-04-28 15:06:11 +02:00
To dump large tables, you should combine the
2009-05-25 11:59:47 +02:00
\fB \- \- single\- transaction\fR
2010-04-28 15:06:11 +02:00
option with
2009-09-16 14:03:18 +02:00
\fB \- \- quick\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: skip-comments option
. \" skip-comments option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- skip\- comments\fR
.sp
See the description for the
\fB \- \- comments\fR
2009-09-16 14:03:18 +02:00
option\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: skip-opt option
. \" skip-opt option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- skip\- opt\fR
.sp
See the description for the
\fB \- \- opt\fR
2009-09-16 14:03:18 +02:00
option\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: socket option
. \" socket option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- socket=\fR \fB \fI path\fR \fR ,
\fB \- S \fR \fB \fI path\fR \fR
.sp
For connections to
2009-09-16 14:03:18 +02:00
localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: SSL options
. \" SSL options: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- ssl*\fR
.sp
Options that begin with
\fB \- \- ssl\fR
2009-09-16 14:03:18 +02:00
specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates\& . See
2010-04-28 15:06:11 +02:00
Section\ \& 5.5.6.3, \(lq SSL Command Options\(rq \& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: tab option
. \" tab option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- tab=\fR \fB \fI path\fR \fR ,
\fB \- T \fR \fB \fI path\fR \fR
.sp
2010-04-28 15:06:11 +02:00
Produce tab\- separated text\- format data files\& . For each dumped table,
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
creates a
2009-09-16 14:03:18 +02:00
\fI tbl_name\fR \& .sql
2009-05-25 11:59:47 +02:00
file that contains the
CREATE TABLE
2010-04-28 15:06:11 +02:00
statement that creates the table, and the server writes a
2009-09-16 14:03:18 +02:00
\fI tbl_name\fR \& .txt
file that contains its data\& . The option value is the directory in which to write the files\& .
.if n \{ \
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
. \}
.RS 4
2009-05-25 11:59:47 +02:00
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
2009-09-16 14:03:18 +02:00
.ps +1
2009-05-25 11:59:47 +02:00
\fB Note\fR
2009-09-16 14:03:18 +02:00
.ps -1
.br
2009-05-25 11:59:47 +02:00
This option should be used only when
\fB mysqldump\fR
is run on the same machine as the
\fB mysqld\fR
2009-09-16 14:03:18 +02:00
server\& . You must have the
2009-05-25 11:59:47 +02:00
FILE
2009-09-16 14:03:18 +02:00
privilege, and the server must have permission to write files in the directory that you specify\& .
.sp .5v
.RE
2010-04-28 15:06:11 +02:00
By default, the
\& .txt
data files are formatted using tab characters between column values and a newline at the end of each line\& . The format can be specified explicitly using the
\fB \- \- fields\- \fR \fB \fI xxx\fR \fR
and
\fB \- \- lines\- terminated\- by\fR
options\& .
.sp
As of MySQL 5\& .1\& .38, column values are converted to the character set specified by the
\fB \- \- default\- character\- set\fR
option\& . Prior to 5\& .1\& .38 or if no such option is present, values are dumped using the
binary
character set\& . 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\& .
2009-09-16 14:03:18 +02:00
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: tables option
. \" tables option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- tables\fR
.sp
Override the
\fB \- \- databases\fR
or
\fB \- B\fR
2009-09-16 14:03:18 +02:00
option\& .
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2009-09-16 14:03:18 +02:00
regards all name arguments following the option as table names\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: triggers option
. \" triggers option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- triggers\fR
.sp
2010-04-28 15:06:11 +02:00
Include triggers for each dumped table in the output\& . This option is enabled by default; disable it with
2009-09-16 14:03:18 +02:00
\fB \- \- skip\- triggers\fR \& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: tz-utc option
. \" tz-utc option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- tz\- utc\fR
.sp
This option enables
TIMESTAMP
2009-09-16 14:03:18 +02:00
columns to be dumped and reloaded between servers in different time zones\& .
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
sets its connection time zone to UTC and adds
2009-09-16 14:03:18 +02:00
SET TIME_ZONE=\' +00:00\'
to the dump file\& . Without this option,
2009-05-25 11:59:47 +02:00
TIMESTAMP
2010-04-28 15:06:11 +02:00
columns are dumped and reloaded in the time zones local to the source and destination servers, which can cause the values to change if the servers are in different time zones\& .
2009-05-25 11:59:47 +02:00
\fB \- \- tz\- utc\fR
2009-09-16 14:03:18 +02:00
also protects against changes due to daylight saving time\& .
2009-05-25 11:59:47 +02:00
\fB \- \- tz\- utc\fR
2009-09-16 14:03:18 +02:00
is enabled by default\& . To disable it, use
\fB \- \- skip\- tz\- utc\fR \& . This option was added in MySQL 5\& .1\& .2\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: user option
. \" user option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- user=\fR \fB \fI user_name\fR \fR ,
\fB \- u \fR \fB \fI user_name\fR \fR
.sp
2009-09-16 14:03:18 +02:00
The MySQL user name to use when connecting to the server\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: verbose option
. \" verbose option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- verbose\fR ,
\fB \- v\fR
.sp
2009-09-16 14:03:18 +02:00
Verbose mode\& . Print more information about what the program does\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: version option
. \" version option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- version\fR ,
\fB \- V\fR
.sp
2009-09-16 14:03:18 +02:00
Display version information and exit\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: where option
. \" where option: mysqldump
\fB \- \- where=\' \fR \fB \fI where_condition\fR \fR \fB \' \fR ,
\fB \- w \' \fR \fB \fI where_condition\fR \fR \fB \' \fR
2009-05-25 11:59:47 +02:00
.sp
Dump only rows selected by the given
WHERE
2009-09-16 14:03:18 +02:00
condition\& . Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter\& .
2009-05-25 11:59:47 +02:00
.sp
Examples:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
\- \- where="user=\' jimf\' "
2009-05-25 11:59:47 +02:00
\- w"userid>1"
\- w"userid<1"
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
.RE
. \}
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
. \" mysqldump: xml option
. \" xml option: mysqldump
2009-05-25 11:59:47 +02:00
\fB \- \- xml\fR ,
\fB \- X\fR
.sp
2009-09-16 14:03:18 +02:00
Write dump output as well\- formed XML\& .
2009-05-25 11:59:47 +02:00
.sp
2010-04-28 15:06:11 +02:00
\fB NULL\fR \fB , \fR \fB \' NULL\' \fR \fB , and Empty Values\fR : For a column named
2009-05-25 11:59:47 +02:00
\fI column_name\fR , the
NULL
value, an empty string, and the string value
2009-09-16 14:03:18 +02:00
\' NULL\'
are distinguished from one another in the output generated by this option as follows\& .
2009-05-25 11:59:47 +02:00
.TS
allbox tab(:);
l l
l l
l l
l l.
T{
\fB Value\fR :
T}:T{
\fB XML Representation\fR :
T}
T{
NULL (\fI unknown value\fR )
T}:T{
2009-09-16 14:03:18 +02:00
<field name="\fI column_name\fR " xsi:nil="true" />
2009-05-25 11:59:47 +02:00
T}
T{
2009-09-16 14:03:18 +02:00
\' \' (\fI empty string\fR )
2009-05-25 11:59:47 +02:00
T}:T{
2009-09-16 14:03:18 +02:00
<field name="\fI column_name\fR "></field>
2009-05-25 11:59:47 +02:00
T}
T{
2009-09-16 14:03:18 +02:00
\' NULL\' (\fI string value\fR )
2009-05-25 11:59:47 +02:00
T}:T{
2009-09-16 14:03:18 +02:00
<field name="\fI column_name\fR ">NULL</field>
2009-05-25 11:59:47 +02:00
T}
.TE
2009-09-16 14:03:18 +02:00
.sp 1
Beginning with MySQL 5\& .1\& .12, the output from the
2009-05-25 11:59:47 +02:00
\fB mysql\fR
client when run using the
\fB \- \- xml\fR
2010-04-28 15:06:11 +02:00
option also follows the preceding rules\& . (See
2009-09-16 14:03:18 +02:00
the section called \(lq MYSQL OPTIONS\(rq \& .)
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
Beginning with MySQL 5\& .1\& .18, XML output from
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
includes the XML namespace, as shown here:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
shell> \fB mysqldump \- \- xml \- u root world City\fR
2009-09-16 14:03:18 +02:00
<?xml version="1\& .0"?>
<mysqldump xmlns:xsi="http://www\& .w3\& .org/2001/XMLSchema\- instance">
2009-05-25 11:59:47 +02:00
<database name="world">
<table_structure name="City">
<field Field="ID" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
<field Field="Name" Type="char(35)" Null="NO" Key="" Default="" Extra="" />
<field Field="CountryCode" Type="char(3)" Null="NO" Key="" Default="" Extra="" />
<field Field="District" Type="char(20)" Null="NO" Key="" Default="" Extra="" />
<field Field="Population" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
2010-04-28 15:06:11 +02:00
<key Table="City" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="ID"
Collation="A" Cardinality="4079" Null="" Index_type="BTREE" Comment="" />
<options Name="City" Engine="MyISAM" Version="10" Row_format="Fixed" Rows="4079"
Avg_row_length="67" Data_length="273293" Max_data_length="18858823439613951"
Index_length="43008" Data_free="0" Auto_increment="4080"
Create_time="2007\- 03\- 31 01:47:01" Update_time="2007\- 03\- 31 01:47:02"
Collation="latin1_swedish_ci" Create_options="" Comment="" />
2009-05-25 11:59:47 +02:00
</table_structure>
<table_data name="City">
<row>
<field name="ID">1</field>
<field name="Name">Kabul</field>
<field name="CountryCode">AFG</field>
<field name="District">Kabol</field>
<field name="Population">1780000</field>
</row>
2009-09-16 14:03:18 +02:00
\fI \& .\& .\& .\fR
2009-05-25 11:59:47 +02:00
<row>
<field name="ID">4079</field>
<field name="Name">Rafah</field>
<field name="CountryCode">PSE</field>
<field name="District">Rafah</field>
<field name="Population">92020</field>
</row>
</table_data>
</database>
</mysqldump>
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.sp
.RE
.PP
You can also set the following variables by using
\fB \- \- \fR \fB \fI var_name\fR \fR \fB =\fR \fB \fI value\fR \fR
syntax:
2009-09-16 14:03:18 +02:00
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
2009-05-25 11:59:47 +02:00
max_allowed_packet
.sp
2009-09-16 14:03:18 +02:00
The maximum size of the buffer for client/server communication\& . The maximum is 1GB\& .
.RE
.sp
.RS 4
.ie n \{ \
\h '-04'\(bu \h '+03'\c
. \}
.el \{ \
.sp -1
.IP \(bu 2 .3
. \}
2009-05-25 11:59:47 +02:00
net_buffer_length
.sp
2010-04-28 15:06:11 +02:00
The initial size of the buffer for client/server communication\& . When creating multiple\- row
INSERT
statements (as with the
2009-05-25 11:59:47 +02:00
\fB \- \- extended\- insert\fR
or
2010-04-28 15:06:11 +02:00
\fB \- \- opt\fR
option),
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
creates rows up to
net_buffer_length
2009-09-16 14:03:18 +02:00
length\& . If you increase this variable, you should also ensure that the
2009-05-25 11:59:47 +02:00
net_buffer_length
2009-09-16 14:03:18 +02:00
variable in the MySQL server is at least this large\& .
2009-05-25 11:59:47 +02:00
.RE
.PP
2010-04-28 15:06:11 +02:00
A common use of
2009-05-25 11:59:47 +02:00
\fB mysqldump\fR
2010-04-28 15:06:11 +02:00
is for making a backup of an entire database:
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
shell> \fB mysqldump \fR \fB \fI db_name\fR \fR \fB > \fR \fB \fI backup\- file\& .sql\fR \fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
2010-04-28 15:06:11 +02:00
You can load the dump file back into the server like this:
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
shell> \fB mysql \fR \fB \fI db_name\fR \fR \fB < \fR \fB \fI backup\- file\& .sql\fR \fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
Or like this:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
shell> \fB mysql \- e "source \fR \fB \fI /path\- to\- backup/backup\- file\& .sql\fR \fR \fB " \fR \fB \fI db_name\fR \fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
\fB mysqldump\fR
is also very useful for populating databases by copying data from one MySQL server to another:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
shell> \fB mysqldump \- \- opt \fR \fB \fI db_name\fR \fR \fB | mysql \- \- host=\fR \fB \fI remote_host\fR \fR \fB \- C \fR \fB \fI db_name\fR \fR
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
It is possible to dump several databases with one command:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
shell> \fB mysqldump \- \- databases \fR \fB \fI db_name1\fR \fR \fB [\fR \fB \fI db_name2\fR \fR \fB \& .\& .\& .] > my_databases\& .sql\fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
To dump all databases, use the
\fB \- \- all\- databases\fR
option:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
shell> \fB mysqldump \- \- all\- databases > all_databases\& .sql\fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
For
InnoDB
tables,
\fB mysqldump\fR
provides a way of making an online backup:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
shell> \fB mysqldump \- \- all\- databases \- \- single\- transaction > all_databases\& .sql\fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
This backup acquires a global read lock on all tables (using
2009-09-16 14:03:18 +02:00
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
2009-05-25 11:59:47 +02:00
FLUSH
2010-04-28 15:06:11 +02:00
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\& .
2009-05-25 11:59:47 +02:00
.PP
For point\- in\- time recovery (also known as
\(lq roll\- forward,\(rq
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
2009-09-16 14:03:18 +02:00
Section\ \& 5.2.4, \(lq The Binary Log\(rq ) or at least know the binary log coordinates to which the dump corresponds:
2009-05-25 11:59:47 +02:00
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
2009-09-16 14:03:18 +02:00
shell> \fB mysqldump \- \- all\- databases \- \- master\- data=2 > all_databases\& .sql\fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
Or:
.sp
2009-09-16 14:03:18 +02:00
.if n \{ \
.RS 4
. \}
2009-05-25 11:59:47 +02:00
.nf
shell> \fB mysqldump \- \- all\- databases \- \- flush\- logs \- \- master\- data=2\fR
2009-09-16 14:03:18 +02:00
\fB > all_databases\& .sql\fR
2009-05-25 11:59:47 +02:00
.fi
2009-09-16 14:03:18 +02:00
.if n \{ \
2009-05-25 11:59:47 +02:00
.RE
2009-09-16 14:03:18 +02:00
. \}
2009-05-25 11:59:47 +02:00
.PP
The
\fB \- \- master\- data\fR
and
\fB \- \- single\- transaction\fR
2010-04-28 15:06:11 +02:00
options can be used simultaneously, which provides a convenient way to make an online backup suitable for use prior to point\- in\- time recovery if tables are stored using the
2009-05-25 11:59:47 +02:00
InnoDB
2009-09-16 14:03:18 +02:00
storage engine\& .
2009-05-25 11:59:47 +02:00
.PP
For more information on making backups, see
2010-04-28 15:06:11 +02:00
Section\ \& 6.2, \(lq Database Backup Methods\(rq , and
Section\ \& 6.3, \(lq Example Backup and Recovery Strategy\(rq \& .
2009-09-16 14:03:18 +02:00
. \" mysqldump: views
. \" mysqldump: problems
. \" mysqldump: workarounds
2009-05-25 11:59:47 +02:00
.PP
2009-09-16 14:03:18 +02:00
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
Section\ \& D.4, \(lq Restrictions on Views\(rq \& .
2009-05-25 11:59:47 +02:00
.SH "COPYRIGHT"
2009-09-16 14:03:18 +02:00
.br
2009-05-25 11:59:47 +02:00
.PP
2010-04-28 15:06:11 +02:00
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.
2009-05-25 11:59:47 +02:00
.PP
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.
.PP
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.
.PP
2009-09-16 14:03:18 +02:00
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/.
.sp
.SH "NOTES"
.IP " 1." 4
Bug#30123
.RS 4
2010-04-28 15:06:11 +02:00
\% http://bugs.mysql.com/bug.php?id=30123
2009-09-16 14:03:18 +02:00
.RE
2009-05-25 11:59:47 +02:00
.SH "SEE ALSO"
For more information, please refer to the MySQL Reference Manual,
which may already be installed locally and which is also available
online at http://dev.mysql.com/doc/.
.SH AUTHOR
2009-09-16 14:03:18 +02:00
Sun Microsystems, Inc. (http://www.mysql.com/).