Home > database >  Under WINDOWS using the batch file to backup the MYSQL database instance, for your reference
Under WINDOWS using the batch file to backup the MYSQL database instance, for your reference

Time:10-10

@ echo off
Rem replaced character set, corresponding there will be a Chinese character set is not garbled
CHCP 65001
Color 0 a

The title platform system data backup
Echo start backup, please wait...
Echo the backup completed before, please do not close this window...

Rem date
Set datestring=% date: date: ~ 0, 4 _ % % % _ % date: ~ 5, 2 ~ 8, 2 %

Rem if date format not yyyy dd/mm/week
If "% % datestring: ~ 0, 1" GTR "9" (
Set datestring=% date: date: ~ - 10, 4 _ % % % _ % ~ - 5, 2 date: ~ % 2, 2)

Rem time
Time: set timestring=% % _ % ~ 0, 2 time: ~ % _ % time: 3, 2 ~ 6, %
Echo timestring % %

Rem storage backup file path
The set backpath=e: \ MySQLbackup
If not exist back_path md back_path % % % %

Rem database name
Set the database=database name
Rem user name
Set the username=account name
Rem password
Set the password=password

Rem database backup mysqldump. Exe directory path (if address contains Spaces, need to be included in double quotation marks in English)
Set the mysql=d: \ mysql \ bin
Rem filename
Set file_string backpath=% % \ timestring _ datestring data_ % % % %
Echo file_string % %
Rem backup
Mysql rem % % \ mysqldump exe -u username % % -p password database % % % % & gt; SQL
% file_string %.Mysql % % \ mysqldump exe - username u % % - p % database % & gt; "% % file_string. The SQL"
Echo backup!
Pause
@ echo on
  • Related