mysqldump备份Mysql数据

mysqldump的命令可以参考這个:

http://www.cnblogs.com/qq78292959/p/3637135.html

http://www.cnblogs.com/chenmh/p/5300370.html

定时执行可以使用windows的计划任务。

以下是一个bat实例:

echo 
set yy=%date:~0,4%
set mm=%date:~5,2%
set dd=%date:~8,2%
if /i %time:~0,2% lss 10 set hh=0%time:~1,1%
if /i %time:~0,2% geq 10 set hh=%time:~0,2%
set mn=%time:~3,2%
set ss=%time:~6,2%
set date=%yy%%mm%%dd%
set time=%hh%%mn%%ss%
set filename=%date%_%time%

"D:/Program Files/MySQL/MySQL Server 5.6/bin/mysqldump.exe" --opt --port=端口 --host=IP地址 --skip-comments --single-transaction --default-character-set=utf8 --no-create-info weipandb_new t_account t_capital t_capital_io t_hold t_order t_ticket tb_mbroker tb_qbroker > D:/MySQL_DB_Back/天津联合/weipandb_tjlh_%filename%.sql

  注意:bat中写入密码一直没办法成功登录mysql进行备份,因此我采用的是在mysql的配置文件my.ini中写上用户名和密码。

[mysqldump]
user=用户名
password=密码

  

原文地址:https://www.cnblogs.com/CarlBlogs/p/7405144.html