Use WinRAR to perform a scheduled backup of the MySQL Tutorial database tutorial.
For MySQL backup, the best way is to directly back up the MySQL database data directory. A method of using WinRAR to perform a scheduled backup of the data directory is provided below.
First of all, of course, install the WinRAR on the computer.
Write the following command to a text file
net stop MySQL
Del d:mysqldata/q
C:progra~1winrarwinrar a-ag-k-r-s D:mysql.rar d:mysqldata
net start MySQL
Save, and then modify the extension of the text file to cmd.
Enter the control Panel, open the Scheduled task, and double-click Add Scheduled task. In the Scheduled Task Wizard, locate the cmd file just now, and then specify a run-time and run-time account password for this task.
The following hypothetical environment:
MySQL Installation location: c:mysql
Forum database name: BBS
Database backup destinations: C:db_bak
============================
Create a new 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
You can then use Windows Scheduled Tasks to execute the batch script at timed intervals. (For example: Perform Back_db.bat 3 o'clock in the morning every day)
Explanation: Backup and restore operations are relatively simple, integrity is relatively high, control backup cycle is more flexible, for example, save a week of data, with%date:~0,3%, save the daily data, with%date:~4,10%. This method is suitable for users who have a standalone host but have no management experience with MySQL. The disadvantage is that a lot of space, the backup period MySQL will be a short time to disconnect (for example: about 30m of the database takes about 5s).
==============
Hypothetical environment:
MySQL Installation location: c:mysql
Forum database name: BBS
MySQL root password: 123456
Database backup destinations: 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 above code as Backup_db.bat
You can then use Windows Scheduled Tasks to execute the script at timed intervals. (For example: Perform Back_db.bat 5 o'clock in the morning every day)