On a Windows server, if you want to back up database data on a regular basis, you can use the Windows Task Scheduler + database backup script combination. Among them, mysqldump plays a key role in MySQL database backup. For information about the usage of the mysqldump command, you can find the official documentation of MySQL. 1 Backup Script@echo off echo Set the connection information of MySql database set host=127.0.0.1 set port=3306 set user=root set pass=admin echo Set the name of the MySql database to be backed up set dbname=test echo gets the date format of the day, for example: 20200902231300 set hour=%time:~0,2% if "%time:~0,1%"==" " set hour=0%time:~1,1% set backup_date=%Date:~0,4%%Date:~5,2%%Date:~8,2%%hour%%Time:~3,2%%Time:~6,2% echo Set the path of the backup file set backupfile=D:\mysql\beifen\%dbname%-%backup_date%.sql echo Use mysqldump to back up the specified MySql echo Note that if there is a space in the path, add double quotes "C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump" -h%host% -P%port% -u%user% -p%pass% -c --add-drop-table %dbname% > %backupfile% echo delete expired files, here it is deleted after more than 30 days forfiles /p D:\mysql\beifen /s /m *.sql /d -30 /c "cmd /c del @file /f" 2 Backup Success Screenshot Method 2: Mysql automatic backup script under Windows:: The MySQL version used when writing the script is mysql5.5.16 Ver 14.14 Distrib 5.5.16, for Win32 (x86) :: This script is used to save a database:: Configure script parameters:: Configure database user SET DB_USER=root :: Configure database password SET DB_PASSWORD=yuanse3366 :: Configure the backup database name SET DB_NAME=soms :: Configure the backup file path SET SAVE_PATH=D:\databack\data :: Configure the path of mysqldump SET MYSQL_DUMP_PATH=D:\wamp\mysql\bin\mysqldump.exe :: Start working:: Jump to the working directory %SAVE_PATH:~0,2% cd %SAVE_PATH% :: Set variable: backup file name SET BAK_FILE=%SAVE_PATH%\soms_bak_%date:~0,4%_%date:~5,2%_%date:~8,2%_%time:~0,2%_%time:~3,2%.sql :: Start backup %MYSQL_DUMP_PATH% -u%DB_USER% -p%DB_PASSWORD% %DB_NAME% --lock-all-tables -r%BAK_FILE% Copy the above script and save it as a BAT file, modify the configuration parameters, and then add it to the Windows scheduled task. This is the end of this article about the implementation of MySQL scheduled backup script under Windows. For more relevant MySQL scheduled backup script content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Web page creation question: Image file path
>>: js tag syntax usage details
This article shares the specific code of JS to ac...
In the past, float was often used for layout, but...
Disable right-click menu <body oncontextmenu=s...
This article introduces MySQL string interception...
Table of contents 1: Prepare https certificate 2:...
Here are a few ways to remove it: Add the link dir...
This article example shares the specific code for...
Recently, I solved the problem of Docker and the ...
When implementing this function, the method I bor...
This article is a simple calculator written using...
This article example shares the specific code of ...
Make a nice flip login and registration interface...
introduction When I was learning more about datab...
Written in front In the past and in the current p...
one. wget https://dev.mysql.com/get/mysql57-commu...