Backing up a database using mysqldump

Source: Internet
Author: User

  1. Backing up a database using mysqldump
  2. 1. Backing up a database
  3. mysqldump--user [user name] --password=[password] [database name] > [dump file]
  4. Or
  5. Mysqldump-u[user name]-p[password] [database name] > [dump file]
  6. Example:
  7. mysqldump--user root --password=myrootpassword db_test > Db_test.sql
  8. Or
  9. Mysqldump-uroot-p Myrootpassword db_test > Db_test.sql
  10. 2. Backing up multiple databases
  11. Mysqldump-u[user name]-p[password] [database name 1] [database name 2]. > [dump file]
  12. Example:
  13. mysqldump--user root --password=myrootpassword db_test db_second db_third > Db_test.sql
  14. 3. Back up all databases
  15. mysqldump-u [user Name]-p [password]--all-databases > [dump file]
  16. 4. Back up a table
  17. Mysqldump--user [username] --password=[password] [database name] [table name]/tmp/sugarcrm_accounts_contacts.sql
  18. Example:
  19. mysqldump--user root --password=myrootpassword db_test customers db_test_customers.sql
  20. 5. Recovering a Database
  21. MySQL--u [username] --password=[password] [database name] < [dump file]
  22. Example:
  23. MySQL--user root --password=myrootpassword new_db < db_test.sql

The mysqldump command is used to back up the database.

The mysqldump command executes under the DOS [Url=file://\\mysql\\bin]\\mysql\\bin[/url] directory.

1) Export the entire database (the export file is present in the Mysql\bin directory by default)
Mysqldump-u user name-p database name > exported file name
Mysqldump-u user_name-p123456 database_name > Outfile_name.sql

2) export a table
Mysqldump-u user name-P database name Table name > exported file name
MYSQLDUMP-U USER_NAME-P database_name table_name > OUTFILE_NAME.SQL

3) Export a database structure
Mysqldump-u user_name-p-d–add-drop-table database_name > Outfile_name.sql
-D No data –add-drop-table add a drop table before each CREATE statement

4) Export with language parameters
mysqldump-uroot-p–default-character-set=latin1–set-charset=gbk–skip-opt database_name > Outfile_name.sql

For example, back up the AAA library to file Back_aaa:
[Email protected] root]# Cd/home/data/mysql
[Email protected] mysql]# mysqldump-u root-p--opt aaa > BACK_AAA

Backing up a database using mysqldump

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.