The precondition is that you need to have the server control permission, so that we can use the cmd command and windows scheduled task to implement timed execution of the bat batch file we wrote to back up mysql database files.
First, we wrote a. bat file for processing. The Code is as follows:
The Code is as follows: |
Copy code |
Net stop mysql Xcopy D: phpStudyMySQLdataabc *. * D: up % date :~ 0, 10%/y Net start mysql |
Note: abc is the name of your database, and up is the name you want to back up to the specified directory. Later, the date reference is the directory generation date, for example, up.
Now we have written the batch processing file and started to plan the task.
1. Find it in "start-> Program-> attachment-> System Tools" on windows and open the "scheduled task" window.
2. Find the path of your a. bat file.
3. The execution cycle can be selected below. Here we select daily.
4. Enter the specific time point, which can be accurate to minutes. A logon password for the computer will be entered later. Try to enter the password. Otherwise, the backup will fail, you cannot back up the data without a password.
5. KO is finished.