mytest.bat文件内容如下
@echo off set backup_date=%date:~0,4%%date:~5,2%%date:~8,2% set db_name=db_test01 db_test02 db_test03 for %%i in (%db_name%) do (mysqldump -h localhost -uroot -pmysql -P13306 %%i --default-character-set=utf8 --set-gtid-purged=OFF --skip-tz-utc --skip-disable-keys --skip-add-locks --single-transaction --master-data=2 >D:\mysqlbak\%%i_%backup_date%bak.sql) set dbbak_dir=D:\mysqlbak\ echo 删除7天前的备份文件…… echo. forfiles /P %dbbak_dir% /D -2 -M *bak.sql /C "cmd /c del @file" pause
中文显示乱码的解决办法:将该文件以ANSI格式另存。
标签:set,--,skip,db,%%,windowds,mysqldump,MySQL,date From: https://www.cnblogs.com/hxlasky/p/17374084.html