mysqlimport
— A Data Import Program
308
shell>
mysqldump --opt db_name | mysql --host=remote_host -C db_name
It is possible to dump several databases with one command:
shell>
mysqldump --databases db_name1 [db_name2 ...] > my_databases.sql
To dump all databases, use the
--all-databases
[298]
option:
shell>
mysqldump --all-databases > all_databases.sql
For
InnoDB
tables,
mysqldump
provides a way of making an online backup:
shell>
mysqldump --all-databases --single-transaction > all_databases.sql
This backup acquires a global read lock on all tables (using
FLUSH TABLES WITH READ LOCK
) at
the beginning of the dump. As soon as this lock has been acquired, the binary log coordinates are read
and the lock is released. If long updating statements are running when the
FLUSH
statement is issued,
the MySQL server may get stalled until those statements finish. After that, the dump becomes lock free
and does not disturb reads and writes on the tables. If the update statements that the MySQL server
receives are short (in terms of execution time), the initial lock period should not be noticeable, even
with many updates.
For point-in-time recovery (also known as “roll-forward,” when you need to restore an old backup
and replay the changes that happened since that backup), it is often useful to rotate the binary log
(see
Section 5.2.3, “The Binary Log”
) or at least know the binary log coordinates to which the dump
corresponds:
shell>
mysqldump --all-databases --master-data=2 > all_databases.sql
Or:
shell>
mysqldump --all-databases --flush-logs --master-data=2
> all_databases.sql
The
--master-data
[302]
and
--single-transaction
[304]
options can be used
simultaneously, which provides a convenient way to make an online backup suitable for use prior to
point-in-time recovery if tables are stored using the
InnoDB
storage engine.
For more information on making backups, see
Section 7.2, “Database Backup Methods”
, and
Section 7.3, “Example Backup and Recovery Strategy”
.
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 E.4, “Restrictions on Views”
.
4.5.5.
mysqlimport
— A Data Import Program
The
mysqlimport
client provides a command-line interface to the
LOAD DATA INFILE
SQL
statement. Most options to
mysqlimport
correspond directly to clauses of
LOAD DATA INFILE
syntax. See
Section 13.2.6, “
LOAD DATA INFILE
Syntax”
.
Invoke
mysqlimport
like this:
shell>
mysqlimport [options] db_name textfile1 [textfile2 ...]
For each text file named on the command line,
mysqlimport
strips any extension from the file name
and uses the result to determine the name of the table into which to import the file's contents. For
example, files named
patient.txt
,
patient.text
, and
patient
all would be imported into a table
named
patient
.
mysqlimport
supports the following options, which can be specified on the command line or in the
[mysqlimport]
and
[client]
groups of an option file.
mysqlimport
also supports the options for
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...