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