用.bat文件备份mysql数据库

@echo off
set errorlevel=0
set path_home_mysql="D:\SU2008\MySQL Server 5.0\"
set path_bin_mysql=%path_home_mysql%bin\

set opt_mysql=--add-drop-database --add-drop-table
set database_mysql=--databases test 

set user_mysql=root      
set password_mysql=root

set backup_dir=%path_home_mysql%db_backup

set backup_file=%backup_dir%mysql_backup_%date:~0,10%.sql

dir %backup_dir%

IF EXIST %backup_file% ( del %backup_file% &echo %backup_file% is deleted)

echo backup mysql database:%database_mysql%

%path_bin_mysql%mysqldump -u%user_mysql% -p%password_mysql% %database_mysql% %opt_mysql% > %backup_file%

echo end backup
::D:\SU2008\MySQL Server 5.0\为MySql安装目录 test为数据库名 root root 用户名密码

 

加入到windows计划任务,可实现每天定时备份

你可能感兴趣的:(软件设计&其它,MySQL,SQL,Server,SQL,Windows)