10. Simple usage of mysqldump

Source: Internet
Author: User

1. mysqldump-A database backup program

Mysqldump [Options] [db_name [tbl_name...]

If you do not specify any tables, the entire database will be exported.

2. Option [2]

-- Opt optimizes the table's dump speed and writes the dump file, which is the best reload speed. This option enables-add-drop-table, -- add-locks, -- all -- extended-insert, -- quick, and -- lock-tables.

3. Example

1) Export the database

①Export the table structure whose database is dbname (the username is root, the password is dbpasswd, And the generated Script Name Is dB. SQL)

Mysqldump-u root-P dbpasswd-D dbname> dB. SQL;

②The exported database is a dbname table (TEST) structure.

Mysqldump-u root-P dbpasswd-D dbname test> dB. SQL;

③Export all table structures and table data (without-d) in the database as dbname)

Mysqldump-u root-P dbpasswd dbname> dB. SQL;

④Export Database to dbname a table (TEST) structure and table data (without-d)

Mysqldump-u root-P dbpasswd dbname test> dB. SQL;

⑤Export with language Parameters

Mysqldump-uroot-p -- default-character-set = Latin1 -- Set-charset = GBK -- skip-opt Databse> dB. SQL

2) import the database

①Shell> mysqladmin create target_db_name

Shell> MySQL target_db_name <backup-file. SQL

②Mysqldump-H localhost-u root-PDbpasswd dbname>Dbname_bak. SQL

③Use my_db // the database to be exported

Source/var/mysqldata/mysql2007. SQL // execute Import

Reference

[1]Http://linux.die.net/man/1/mysqldump

[2] Translation of options

Http://www.blogjava.net/Alpha/archive/2007/08/10/135694.html

[3]Http://www.cnblogs.com/yuanyouqi/archive/2010/04/28/1722738.html

[4] detailed introduction to Database Backup

Http://hi.baidu.com/li_shen/blog/item/a85646235e7f9041ac34de4e.html

Http://www.haogongju.net/art/699827

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.