Windows 下 MySQL 備份腳本


 1 @title MySQL備份腳本
 2 @echo off
 3 @echo root@127.0.0.1:3306
 4 set host=127.0.0.1
 5 set port=3306
 6 set user=root
 7 @echo 請輸入數據庫密碼
 8 set /p password=
 9 @echo 請輸入需要備份的數據庫
10 @set /p database=
11 set mysqldumppath=d:\mysql\bin
12 set resultfilepath=e:
13 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" set curtime=04
21 if "%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

可以簡單修改下腳本將要輸入的內容寫定,加入計划任務中,每次開機自動備份一次MySQL數據庫。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM