DB2 与 MySQL 数据转移
2007-02-19 10:54:51 来源:WEB开发网核心提示: mysqldump --opt db_name > backup-file.sql导入它的方法是发出以下命令:清单 2. 使用 mysqldump 导入完整的数据库mysql db_name < backup-file.sql清单 3 中列出了 mysqldump 支持的一些重
mysqldump --opt db_name > backup-file.sql
导入它的方法是发出以下命令:
清单 2. 使用 mysqldump 导入完整的数据库
mysql db_name < backup-file.sql
清单 3 中列出了 mysqldump 支持的一些重要标志。发出 mysqldump -? 命令可以获得完整的列表。
清单 3. mysqldump 选项
-A, --all-databases Dump all the databases. This will be same as --databases
with all databases selected.
--add-drop-database Add a 'DROP DATABASE' before each create.
--add-drop-table Add a 'drop table' before each create.
--add-locks Add locks around insert statements.
--allow-keywords Allow creation of column names that are keywords.
--character-sets-dir=name
Directory where character sets are.
-c, --complete-insert
Use complete insert statements.
-C, --compress Use compression in server/client protocol.
--create-options Include all MySQL specific create options.
-B, --databases To dump several databases. Note the difference in usage;
In this case no tables are given. All name arguments are
regarded as databasenames. 'USE db_name;' will be
included in the output.
Set the default character set.
--delayed-insert Insert rows with INSERT DELAYED;
--delete-master-logs
Delete logs on master after backup. This automatically
enables --master-data.
-e, --extended-insert
Allows utilization of the new, much faster INSERT syntax.
--fields-terminated-by=name
Fields in the textfile are terminated by ...
--fields-enclosed-by=name
Fields in the importfile are enclosed by ...
--fields-optionally-enclosed-by=name
Fields in the i.file are opt. enclosed by ...
--fields-escaped-by=name
Fields in the i.file are escaped by ...
--order-by-primary Sorts each table's rows by primary key, or first unique
key, if such a key exists. Useful when dumping a MyISAM
table to be loaded into an InnoDB table, but will make
the dump itself take considerably longer.
--single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. Option
automatically turns off --lock-tables.
-T, --tab=name Creates tab separated textfile for each table to given
path. (creates .sql and .txt files). NOTE: This only
works if mysqldump is run on the same machine as the
mysqld daemon.
--tables Overrides option --databases (-B).
--triggers Dump triggers for each dumped table
-X, --xml Dump a database as well formed XML.
尽管 mysqldump 适合对中小规模的表和数据库进行备份,但是 mysqlhotcopy 的能力更强。不过要注意,mysqlhotcopy 不具有 mysqldump 那么大的灵活性。要记住一点,它只能在数据库目录所在的机器上运行。
更多精彩
赞助商链接