批处理备份和恢复mysql数据库

时间:2021-06-19 14:54:47

备份

set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%"
md "D:\databackup\%Ymd%"
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump.exe" --opt -Q databasename -uroot -p123456 > D:\databackup\databasename%Ymd%.sql

@echo off
mshta vbscript:msgbox("mysql backup successed!!!",6,"mysql backup")(window.close)

恢复

"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe" -uroot -p123456 ensjp < D:\databackup\databasename.sql
@echo off
mshta vbscript:msgbox("mysql restore successed!!!",6,"mysql restore")(window.close)