MySQL backup and restoration database Batch Processing

Source: Internet
Author: User
Tags mysql backup

1. Backup database (single table backup) bk_table.bat

CopyCode The Code is as follows: mysqldump-h127.0.0.1-p3306-uroot-proot -- default-character-set = GBK-T database1 Table1> table1. SQL
Mysqldump-h127.0.0.1-p3306-uroot-proot -- default-character-set = GBK-T database2 Table2> table2. SQL
Mysqldump-h127.0.0.1-p3306-uroot-proot -- default-character-set = GBK-T database2 table3> table3. SQL
Pause

2. Restore the database (restoring a single table) Restore. bat Copy codeThe Code is as follows: mysql-h127.0.0.1-p3306-uroot-proot database1 <table1. SQL
Mysql-h127.0.0.1-p3306-uroot-proot database2 <table2. SQL
Mysql-h127.0.0.1-p3306-uroot-proot database2 <table3. SQL
Pause

336620.data warehouse and automatically compress it into a. rar file (single table backup) bk_table.bat Copy codeThe Code is as follows: mysqldump-h127.0.0.1-p3306-uroot-proot -- default-character-set = GBK-T database1 Table1> table1. SQL
Mysqldump-h127.0.0.1-p3306-uroot-proot -- default-character-set = GBK-T database2 Table2> table2. SQL
Mysqldump-h127.0.0.1-p3306-uroot-proot -- default-character-set = GBK-T database2 table3> table3. SQL
WinRAR A db_bak _ % Date :~ 0, 102.16.rar D: \ db_backup \ *. SQL
Del D: \ db_backup \ *. SQL
Pause

After the batch processing, your backup data script will be compressed to the db_bak_date.rar file on your computer D: \ db_backup.
If 'winrar 'is not an internal or external command, it cannot be run.ProgramOr batch files ." Error: Go to computer> Properties> advanced> environment variable> In Path
Add your WinRAR path, such as c: \ Program Files \ WinRAR.
4. Back up the data of the entire database Copy codeThe Code is as follows: mysqldump-h127.0.0.1-p3306-uroot-proot database1> database1. SQL
Pause

Note:
1. Open notepad-> copy the above script to notepad-> save it as the *. BAT file, and double-click it to open and execute it.
2. You need to add the path of your MySQL installation bin directory to the path of the computer environment variable:
Computer-> properties-> advanced-> environment variable-> Add your MySQL installation bin directory path in path, for example, c: \ Program Files \ mysql \ MySQL Server 5.0 \ bin
Or copy the batch file to the bin directory c: \ Program Files \ mysql \ MySQL Server 5.0 \ bin for execution.
All of the above have been tested ~

Related Article

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.