建立bat文件
需要在bat的同级目录放入7z.dll和7z.exe还有mysqldump.exe这3个文件
echo off cls REM ===========configure(start)============== set host=服务器IP地址 set port=数据库端口号 set user=用户名 set pass=密码 set dbname=数据库名 set character=utf8 REM ===========configure(end)============== set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%" set h=%time:~0,2% set h=%h: =0% set "His=%h%%time:~3,2%%time:~6,2%" echo %Ymd%%His% mkdir "%~dp0/sql" mkdir "%~dp0/log" set targetsql="%~dp0/sql/%dbname%.sql" "%~dp0/mysqldump.exe" --default-character-set=%character% --routines -h%host% -P%port% -u%user% -p%pass% %dbname%>%targetsql% "%~dp0/7z.exe" a -txz "%~dp0/sql/%dbname%_%Ymd%%His%.xz" %targetsql% >"%~dp0/log/%Ymd%%His%.log"
把以上内容保存为BAT,然后放入控制面板里的计划任务设置即可