MySQL backup and restoration database batch processing bitsCN.com
1. backup database (single table backup) bk_table.bat
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
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
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, or a program or batch file that can be run ." 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
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 Server 5.0/bin
Or copy the batch file to the bin directory C:/Program Files/MySQL Server 5.0/bin for execution.
All of the above have been tested ~
BitsCN.com