how to take backup and restore of mysql database in vb.net
hello to all i m making a project in vb.net now i want to give utility of backup and restore database in window application vb.net
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Posted Oct 13, 2010, 8:35 AM
Call the batch file in .net.
http://www.dotnetspider.com/resources/19537-MySQL-Database-Backup-Restore-from-C-NET.aspx
-- For Taking backup
@ECHO off
cls
set DBchoice=%1%
set User=%2%
set Password=%3%
set pathchoice=%4%
@REM Remove double quotes from the path
@REM SET pathchoice=%pathchoice:"=%
@REM SET pathchoice=%pathchoice:"=%
mysqldump --add-drop-table -B %DBchoice% -u %User% --password=%Password% > %pathchoice%
-- To Restore :
@ECHO off
cls
set User=%1%
set Password=%2%
set DBchoice=%3%
set pathchoice=%4%
set hostIP=%5%
set toolPath=%6%
@REM Remove double quotes from the path
@REM SET pathchoice=%pathchoice:"=%
@REM SET pathchoice=%pathchoice:"=%
%toolPath%\mysql -u %User% -h%hostIP% --password=%Password% %DBchoice% < %pathchoice%
http://www.dotnetspider.com/resources/19537-MySQL-Database-Backup-Restore-from-C-NET.aspx
To make backup
here is the vb code :
process.start("C:program files/mysql/bin/mysqldum.exe","-u username -p password --database=dbname > -r ""C:\back.sql""")
To restore
process.start("C:\porgram files\mysql\bin\mysql.exe","-u username -p password --database=dbname > -r ""C:\back.sql""")
http://forums.mysql.com/read.php?28,18395,181484
http://viralpatel.net/blogs/2009/01/mysql-database-backup-mysql-mysqldump-backup-command.html