Use winrar to regularly back up the mysql tutorial database.
For mysql backup, the best way is to back up the data directory of the mysql database directly. The following provides a method for using winrar to regularly back up the data directory.
First, install winrar on the computer.
Write the following command into a text file
Net stop mysql
Del d: mysqldata/q
C: progra ~ 1 winrarwinrar a-ag-k-r-s d: mysql.rar d: mysqldata
Net start mysql
Save and modify the extension of the text file to cmd.
Go to the control panel, open the scheduled task, and double-click "add scheduled task ". In the scheduled task wizard, find the cmd file and specify a running time and the account and password used for the task.
The following hypothetical environment:
Mysql installation path: c: mysql
Forum Database Name: bbs
Database Backup destination: c: db_bak
======================================
Create db_bak.bat and write the following code
[Copy to clipboard] code:
Net stop mysql
Xcopy c: mysqldatabbs *. * c: db_bakbbs % date :~ 0, 3%/y
Net start mysql
Then run the batch processing script periodically using windows's scheduled task. (For example, execute back_db.bat at every day)
Explanation: backup and recovery operations are relatively simple, with high integrity and Flexible backup cycle control. For example, to save data for one week, use % date :~ 0, 3%, save the daily data, with % date :~ 4,10%. This method is suitable for users who have independent hosts but have no management experience on mysql. The disadvantage is that the database occupies a large amount of space and mysql will be disconnected for a short time during Backup (for example, it takes about 5 seconds for a database of about 30 mb ).
====================
Hypothetical environment:
Mysql installation path: c: mysql
Forum Database Name: bbs
Mysql root Password 123456
Database Backup destination: d: db_backup
Script:
[Copy to clipboard] code:
@ Echo off
C: mysqlbinmysqladmin-u root -- password = 123456 shutdown
C: mysqlbinmysqldump -- opt-u root -- password = 123456 bbs> d: db_backupbbs. SQL
C: mysqlbinmysqld-nt
Save the preceding code as backup_db.bat.
Then, run the script periodically using the "scheduled task" of windows. (For example, execute back_db.bat at every day)