::换成默认的gbk chcp 936 rem ******MySQL backup start******** @echo off ::如果没有则创建数据库文件夹 IF NOT EXIST "D:db_backup" MD "D:db_backup" ::删除超过30天的备份 forfiles /p "D:db_backup" /m *_backup_*.sql -d -30 /c "cmd /c del /f @path" ::定义时间 set data_time=%date:~0,4%%date:~5,2%%date:~8,2% ::定义mysqldump.exe所在目录+mysqldump set "mysqldump=D:programmysql-5.7.21-winx64inmysqldump" ::定义mysql连接 set "mysql_connect=--opt --single-transaction=TRUE --user=root --password=nyt@aA? --host=127.0.0.1 --protocol=tcp --port=3306 --default-character-set=utf8 --single-transaction=TRUE --routines --events" IF NOT EXIST "D:db_backupeucenter" MD "D:db_backupeucenter" %mysqldump% %mysql_connect% "eucenter" > D:db_backupeucentereucenter_backup_%data_time%.sql IF NOT EXIST "D:db_backupmlgl_bm" MD "D:db_backupmlgl_bm" %mysqldump% %mysql_connect% "mlgl_bm" > D:db_backupmlgl_bmmlgl_bm_backup_%data_time%.sql IF NOT EXIST "D:db_backupmlgl_nyt" MD "D:db_backupmlgl_nyt" %mysqldump% %mysql_connect% "mlgl_nyt" > D:db_backupmlgl_nytmlgl_nyt_backup_%data_time%.sql IF NOT EXIST "D:db_backupsdnyt" MD "D:db_backupsdnyt" %mysqldump% %mysql_connect% "sdnyt" > D:db_backupsdnytsdnyt_backup_%data_time%.sql IF NOT EXIST "D:db_backupsaiku" MD "D:db_backupsaiku" %mysqldump% %mysql_connect% "saiku" > D:db_backupsaikusaiku_backup_%data_time%.sql IF NOT EXIST "D:db_backupGIS_dlkj" MD "D:db_backupGIS_dlkj" %mysqldump% %mysql_connect% "GIS_dlkj" > D:db_backupGIS_dlkjGIS_dlkj_backup_%data_time%.sql IF NOT EXIST "D:db_backup cpsc" MD "D:db_backup cpsc" %mysqldump% %mysql_connect% "ncpsc" > D:db_backup cpsc cpsc_backup_%data_time%.sql IF NOT EXIST "D:db_backup cpscjyzt" MD "D:db_backup cpscjyzt" %mysqldump% %mysql_connect% "ncpscjyzt" > D:db_backup cpscjyzt cpscjyzt_backup_%data_time%.sql IF NOT EXIST "D:db_backup cpzz" MD "D:db_backup cpzz" %mysqldump% %mysql_connect% "ncpzz" > D:db_backup cpzz cpzz_backup_%data_time%.sql IF NOT EXIST "D:db_backup jtg" MD "D:db_backup jtg" %mysqldump% %mysql_connect% "njtg" > D:db_backup jtg jtg_backup_%data_time%.sql IF NOT EXIST "D:db_backup ykjfw" MD "D:db_backup ykjfw" %mysqldump% %mysql_connect% "nykjfw" > D:db_backup ykjfw ykjfw_backup_%data_time%.sql IF NOT EXIST "D:db_backup ysczl" MD "D:db_backup ysczl" %mysqldump% %mysql_connect% "nysczl" > D:db_backup ysczl ysczl_backup_%data_time%.sql IF NOT EXIST "D:db_backup ysthj" MD "D:db_backup ysthj" %mysqldump% %mysql_connect% "nysthj" > D:db_backup ysthj ysthj_backup_%data_time%.sql @echo on rem %data_time% rem ******MySQL backup end******** ::pause