一. windows环境下
1.要备份的信息
数据库安装位置:C:/MySQL
数据库名: demo
帐号: root
密码: 123456
2.编写backup.bat脚本如下:
@echo off
set "yMd=%date:~,4%%date:~5,2%%date:~8,2%"
set "hms=%time:~,2%%time:~3,2%%time:~6,2%"
"C:/Program Files (x86)/MySQL/MySQL Server 5.5/bin/mysqldump.exe" -uroot -p123456 demo>D:/mysql_backup_%yMd%-%hms%.sql
@echo on