Home > Database > Mysql Tutorial > 教你用bat脚本备份mysql方法

教你用bat脚本备份mysql方法

WBOY
Release: 2016-06-07 16:16:38
Original
1454 people have browsed it

备份mysql的方法其实有很多,但是并不是所有的mysql都能够在linux下运行。windows下备份也是少不了的。下面小编就教大家用bat脚本备份mysql方法。下面一起来学习用bat脚本备份mysql方法吧! rem rem C:Program FilesWinRAR 需要放到 path 下,才能调用rar cli

  备份mysql的方法其实有很多,但是并不是所有的mysql都能够在linux下运行。windows下备份也是少不了的。下面小编就教大家用bat脚本备份mysql方法。下面一起来学习用bat脚本备份mysql方法吧!

  rem

  rem C:Program FilesWinRAR 需要放到 path 下,才能调用rar cli工具

  rem

  rem 跳转到工作目录下

  f:

  cd f:DBBAK

  rem 设置变量:备份文件名

  SET BAK_FILE=MY_DBBAK_%date:~0,-4%.sql

  rem 设置变量:日志文件名

  SET LOG_FILE=MY_DBBAK.log

  rem 记录日志

  echo "%date%" 》 %LOG_FILE%

  rem 开始做备份

  mysqldump --default-character-set=utf8 -hlocalhost -uroot -R --triggers --single-transaction -B mydb > %BAK_FILE%

  rem 压缩备份文件

  rar a %BAK_FILE%.rar %BAK_FILE%

  rem 删除源文件

  del /F %BAK_FILE%

  echo "%date%" 》 %LOG_FILE%

  echo "" 》 %LOG_FILE%

  部署完脚本后,剩下的就是在系统中添加“计划任务”项目了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template