mysqldump
Tips
629
An alternative to using
mysqlimport
to load the data file is to use the
LOAD DATA INFILE
statement
from within the
mysql
client:
mysql>
USE db1;
mysql>
LOAD DATA INFILE 't1.txt' INTO TABLE t1;
If you used any data-formatting options with
mysqldump
when you initially dumped the table, you must
use the same options with
mysqlimport
or
LOAD DATA INFILE
to ensure proper interpretation of
the data file contents:
shell>
mysqlimport --fields-terminated-by=,
--fields-enclosed-by='"' --lines-terminated-by=0x0d0a db1 t1.txt
Or:
mysql>
USE db1;
mysql>
LOAD DATA INFILE 't1.txt' INTO TABLE t1
->
FIELDS TERMINATED BY ',' FIELDS ENCLOSED BY '"'
->
LINES TERMINATED BY '\r\n';
7.4.5.
mysqldump
Tips
This section surveys techniques that enable you to use
mysqldump
to solve specific problems:
• How to make a copy a database
• How to copy a database from one server to another
• How to dump stored programs (stored procedures and functions and triggers)
• How to dump definitions and data separately
7.4.5.1. Making a Copy of a Database
shell>
mysqldump db1 > dump.sql
shell>
mysqladmin create db2
shell>
mysql db2 < dump.sql
Do not use
--databases
[299]
on the
mysqldump
command line because that causes
USE db1
to
be included in the dump file, which overrides the effect of naming
db2
on the
mysql
command line.
7.4.5.2. Copy a Database from one Server to Another
On Server 1:
shell>
mysqldump --databases db1 > dump.sql
Copy the dump file from Server 1 to Server 2.
On Server 2:
shell>
mysql < dump.sql
Use of
--databases
[299]
with the
mysqldump
command line causes the dump file to include
CREATE DATABASE
and
USE
statements that create the database if it does exist and make it the
default database for the reloaded data.
Alternatively, you can omit
--databases
[299]
from the
mysqldump
command. Then you will need to
create the database on Server 2 (if necessary) and specify it as the default database when you reload
the dump file.
On Server 1:
shell>
mysqldump db1 > dump.sql
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 ...