Wednesday, May 22, 2013

Batch file to backup mysql db


This batch file maybe used to create a daily backup of a mysql database.  Oh and I keep mysqldump.exe in the same folder as this script.

 @ECHO OFF
for /F "tokens=2,3,4 delims=/- " %%a in ("%DATE%") do ( set fdate=%%c%%a%%b ) Set /P dbname=Please enter the database name e.g. appdb: IF "%dbname%"=="" GOTO ERROR_MISSINGPARAM SET /P host=Please enter database hostname/ip, press enter for localhost: IF "%host%"=="" SET host=127.0.0.1 SET /P user=Please enter database username, press enter for root: IF "%root%"=="" SET user=root

Batch file to deploy a Mysql script


This dos batch script can be used to execute a mysql script.  Note: mysql.exe has to be available in the same folder.Replace <> with your schema name.

@ECHO OFF REM TODO Create schema if does not exist. REM TODO Display tables when completed Set /P script=Please enter the script file name e.g. create.sql: IF "%script%"=="" GOTO ERROR_MISSINGPARAM If NOT Exist "%script%" SET script="%~dp0\%script%" If NOT Exist "%script%" GOTO ERROR_FILENOTEXIST SET dbname =appdb SET /P host=Please enter database hostname/ip, press enter for "localhost": IF "%host%"=="" SET host=127.0.0.1 SET /P user=Please enter database username, press enter for "root": IF "%root%"=="" SET user=root

How I manage updates on my database against application versions

This is how I manage to roll out database upgrades and relate them to a specific application release such that when upgrading from an older release all updates of subsequent releases will be applied.  This article uses mysql for demonstration purposes but it might be applied to any database engine.