windows mysql每日数据备份
@echo off
set date=%date:~0,4%%date:~5,2%%date:~8,2%
"E:\phpStudy\PHPTutorial\MySQL\bin\mysqldump.exe" -uroot -proot test > E:\mysqlBackData\mysql_back_%date%.sql
test
数据库名称
新建mysql_back.bat文件复制进去 定时任务每日触发一次
mysqldump.exe文件位置
E:\phpStudy\PHPTutorial\MySQL\bin\mysqldump.exe
E:\mysqlBackData\mysql_back_%date%.sql 备份文件位置 (E:\mysqlBackData文件夹需要手动创建)
E:\mysqlBackData\mysql_back_%date%.sql
mysql 5.6测试无问题 5.7报错
mysqldump: [Warning] Using a password on the command line interface can be insecure.
找到mysql配置文件 .ini 添加
[mysqldump]
user=root
password=root
修改.bat文件 去除帐号和密码
@echo off
set date=%date:~0,4%%date:~5,2%%date:~8,2%
"E:\phpStudy\PHPTutorial\MySQL\bin\mysqldump.exe" test > E:\mysqlBackData\mysql_back_%date%.sql