Windows服务器定时备份数据库

 

@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
C:\MySQL\bin\mysqldump --opt -u root --password=123456 dbname > D:\db_backup\dbname_%Ymd%.sql
@echo on

使用Windows的“计划任务”定时执行该批处理脚本即可

另附一键备份所有数据库的批处理:

D:\xampp\mysql\bin\mysql.exe -uroot -proot -s -N -e "SHOW DATABASES" | for /F "usebackq" %%D in (`findstr /V "information_schema performance_schema"`) do D:\xampp\mysql\bin\mysqldump %%D -uroot -proot > D:\Backup\%%D.sql

476 total views, 2 views today

Revisions

There are no revisions for this post.

No comments yet.

发表评论