MySQL: Backup Database using Batch File ?>

MySQL: Backup Database using Batch File

Backup MySQL Database in Windows

The Backup User

CREATE USER 'backup'@'backup' IDENTIFIED BY 'backup'; 
GRANT FILE, LOCK TABLES, SELECT ON *.* TO 'backup'@'localhost' IDENTIFIED BY 'backup';
FLUSH PRIVILEGES;

The Script

echo off
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
	set dow=%%i
	set month=%%j
	set day=%%k
	set year=%%l
)
set datestr=%year%_%month%_%day%
cd C:wampbinmysqlmysql5.6.12bin
cls
mysqldump --user=backup --password=backup myapp > D:BACKUPSmyapp_%datestr%.sql
echo Database Backups Completed
pause

You may run this script using Scheduler to make your backup by weekly, monthly, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

four + 14 =