- 效果图
- 脚本
@echo on
:: 删除之前已经备份的文件
:: 切换到MYSQL Bin目录
set filename=bpr_%date:~0,4%%date:~5,2%%date:~8,2%.sql
set Pan=d:\
set AFolder="D:\Wang Word\DatabaseBackups\BPR\"
del "D:\Wang Word\DatabaseBackups\BPR\"%filename%
if exist %Pan% (
if exist %AFolder% (
rem 目录d:\<span style="font-family: Arial, Helvetica, sans-serif;">backup</span>已存在,无需创建
echo 目录%AFolder%已存在,无需创建
) else (
rem 创建d:\backup
echo 创建%AFolder%
md %AFolder%
)
cd /d "D:/InternetApplications/MySQL Server 8.0/bin"
:: MySQL 用户名
set USERNAME=root
:: MySQL 密码
set PASSWORD=123456
:: 要备份的数据库名称
set DATABASE=bpr
mysqldump.exe -u%USERNAME% -p%PASSWORD% --default-character-set=utf8 %DATABASE%> "D:\Wang Word\DatabaseBackups\BPR\"%filename%
)else (
echo !!
echo !!执行失败,当前系统上不存在%Pan%盘
echo !!
)
@echo off