. 1 @title the MySQL backup script 2 @echo OFF . 3 @echo [email protected]: 3306 . 4 SET Host = 127.0.0.1 . 5 SET Port = 3306 . 6 SET User = the root . 7 @echo enter the database password . 8 SET / password P = . 9 @echo enter the desired backup database 10 @ SET / = P database . 11 SET mysqldumppath = D: \ MySQL \ bin 12 is SET resultfilepath = E: 13 is SET CURDATE =% DATE : ~ 0,4% -% DATE:~5,2%-%date:~8,2% 14 set curmon=%date:~0,4%%date:~5,2% 15 set curtime=%time:~0,2% 16 if "%curtime%"=="0" set curtime=00 17 if "%curtime%"=="1" set curtime=01 18 if "%curtime%"=="2" set curtime=02 19 if "%curtime%"=="3" set curtime=03 20 if "%curtime%"=="4"if21CURTIME = 04 September "%curtime%"=="5" set curtime=05 22 if "%curtime%"=="6" set curtime=06 23 if "%curtime%"=="7" set curtime=07 24 if "%curtime%"=="8" set curtime=08 25 if "%curtime%"=="9" set curtime=09 26 set curtime=%curtime%-%time:~3,2%-%time:~6,2% 27 set resultfile=%database%_%curdate%_%curtime%.sql 28 @%mysqldumppath%\mysqldump.exe %database% --result-file=%resultfilepath%\%resultfile% --complete-insert --user=%user% --password=%password% --host=%host% --port=%port% 29 @echo 操作结束 30 pause 31 @echo on 32 exit
You can simply modify the contents of the script to be written given input, Join task, each boot automatically back up MySQL database.