MySQL Backup RESTORE Database Batch _mysql

Source: Internet
Author: User
Tags rar mysql backup

1. Backup Database (single table backup) Bk_table.bat

Copy Code code 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 (a single table restore) Restore.bat
Copy Code code 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

3. Backup the database and automatically pack and compress it into a. rar file (a single table backup) Bk_table.bat
Copy Code code 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,10%.rar d:\db_backup\*.sql
DEL D:\db_backup\*.sql
Pause

After the batch process is executed, your backup data script is compressed into the Db_bak_ date. rar file of your computer D:\DB_Backup.
If "' WinRAR ' is not an internal or external command, it is not a running program or a batch file. "Error, in computer-> properties-> Advanced-> environment variable-> in path item
Add your WinRAR path, such as: C:\Program Files\winrar.
4, back up the entire library of data
Copy Code code as follows:

Mysqldump-h127.0.0.1-p3306-uroot-proot database1 > Database1.sql
Pause

Description
1, open Notepad-> the above script copy to Notepad-> Save as *.bat file can double-click to open execution.
2, need to add your MySQL installation bin directory path to the computer environment variable path:
Computer-> Properties-> Advanced-> environment variable-> add your MySQL Installation bin directory path in path entry: 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 execution.
All of these have been tested, O (∩_∩) o~

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.