mysqldump command backup data, source recovery data

Source: Internet
Author: User

mysqldump is a tool used by the database for backup and data transfer, which can be used for backup when the amount of data is small (several grams). When the amount of data is relatively large, it is not recommended to use the Mysqldump tool for backup; mysqldump is a very useful MySQL data transfer tool, with compatible strong, cross-version and other characteristics;

1. Database export:mysqldump can be exported for a single table, multiple tables, a single database, multiple databases, and all databases.

1 ) Normal backup of a single database:

[email protected] tools]# mysqldump –u root-p-s/var/lib/mysql/mysql.sock sky9896>/home/tools/bak_$ (date +%f). SQL

2 ) Compress Backup:

[Email protected] tools]# mysqldump-uroot-p-s/var/lib/mysql/mysql.sock sky9896|gzip >/home/tools/bak_$ (date +%F) . sql.gz

3 How do I make multiple library backups? Key plus parameter '-B ', back up all libraries, add parameter '-a ';

Mysqldump-u User name -p-b Database 1 Database n > backup file name . SQL

[Email protected] tools]# mysqldump-uroot-p-s/var/lib/mysql/mysql.sock-b sky9896 blog >/home/tools/bak_b_$ (dat e +%f). sql

4) How do I make a sub-library backup?

Mysqldump-u User name - P Database > backup file name . SQL

[Email protected] tools]# mysqldump-uroot-p-s/var/lib/mysql/mysql.sock blog >/home/tools/bak_b_$ (date +%f). sql

5 How do I make a backup of a table?

Mysqldump-u User name - P Database name Table name 1 > backup file name . SQL

[[email protected] tools] #mysqldump-u root-p sky9896 test>/home/back/test.sql

6) How do I make multiple table backups?

Mysqldump-u User name - P Database name Table name 1 table name 2 > backup file name . SQL

[[email protected]] #mysqldump-u root-p sky9896 sky1 sky2 >/home/back/sky.sql

7) backing up the database structure ( does not contain data ), Key plus Parameters '-d '

Mysqldump-u User name - P Database name - D Table name > backup file name . SQL

[[email protected]] #mysqldump –u root–p–s/var/lib/mysql/mysql.sock sky9896-d >/home/tools/bak_b_$ (date +%f). SQL

8) Data Recovery

[email protected]]# mysql –u sky9896–p <*.sql

Mysql> Source/home/tools/bak_2015-01-17.sql

This article is from the "Linux~dba~mba" blog, make sure to keep this source http://sky9896.blog.51cto.com/2330653/1605123

mysqldump command backup data, source recovery data

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.