1. Copy the date folder backup
======================================
Hypothetical environment:
MySQL installation path: C:/program files/MySQL Server 5.0
Forum Database Name: Attendance
Database Backup destination: D:/test/attendance/
======================================
Create db_bak.bat and write the followingCode
* ******* Start the BAT file code **********
Net stop MySQL
Xcopy "C:/program files/MySQL Server 5.0/data/attendance/*. *" D:/test/attendance/% Date :~ 0, 10%/S/I
Net start MySQL
@ Echo off
Echo execution ended over
Set/P skysnow =
Echo % skysnow %
* ******* BAT file code ended **********
Then run the batch processing script periodically using Windows's scheduled task. (For example, execute back_db.bat at every day)
Explanation: the backup and recovery operations are simple, the integrity is relatively high, and the backup cycle is controlled flexibly. For example, % Date :~ 0, 10%. This method is suitable for users who have independent hosts but have no management experience on MySQL. The disadvantage is that it takes a lot of space and MySQL will be disconnected for a short time during the backup period (for example, it takes about 5 seconds for a database of about 30 mb), for % Date :~ For usage of %, see.
--------------------------
--------------------------
2. Back up mysqldump to an SQL File
====================
Hypothetical environment:
MySQL installation path: C:/MySQL
Forum Database Name: BBS
MySQL Root Password 123456
Database Backup destination: D:/db_backup/
Script:
* ***************************** Code start ******* **********************
@ Echo off
"C:/MySQL/bin/mysqldump" -- opt-u root -- Password = 123456 BBS> D:/db_backup/BBS. SQL
* ***************************** Code end ******* **********************
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)
"start" → "attachment" → " System Tools ">" task plan "(requires the computer password)