9 Replies - 13095 Views - Last Post: 17 March 2012 - 11:54 PM Rate Topic: -----

#1 les1  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 10-February 12

How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 12:17 AM

I'm creating a program with database and it almost done. The only one thing that left is the backup and restore of database. I don't know how to do this. Any help would be appreciated. :helpsmilie: :helpsmilie:

Is This A Good Question/Topic? 0
  • +

Replies To: How to backup and restore mysql database using vb.net

#2 cj777  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 03-March 12

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 12:26 AM

View Postles1, on 17 March 2012 - 12:17 AM, said:

I'm creating a program with database and it almost done. The only one thing that left is the backup and restore of database. I don't know how to do this. Any help would be appreciated. :helpsmilie: :helpsmilie:

3rd year level BSIT TCA... :bigsmile:
Was This Post Helpful? 0
  • +
  • -

#3 DimitriV  Icon User is online

  • >not activating your almonds
  • member icon

Reputation: 561
  • View blog
  • Posts: 2,676
  • Joined: 24-July 11

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 03:11 AM

At a glance, this seems like it could be useful:
http://webcheatsheet...kup_restore.php
It uses the command line so it is really up to you to decide if you want to muck around with it.
Was This Post Helpful? 0
  • +
  • -

#4 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 221
  • View blog
  • Posts: 1,478
  • Joined: 16-March 11

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 07:27 AM

You could just write your own separate application to grab all the data from the database, and store it into a back up one whenever you want it, or in intervals.
Was This Post Helpful? 0
  • +
  • -

#5 les1  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 10-February 12

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 09:44 AM

I found the solution. :bananaman:

Thanks for the replies
Was This Post Helpful? 0
  • +
  • -

#6 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 10:24 AM

Please be kind enough to share your solution here. It would help someone in the future who wants to do the same.

I'm new to MySQL myself. It would be useful to know how to do it without using commands.

This post has been edited by nK0de: 17 March 2012 - 10:25 AM

Was This Post Helpful? 0
  • +
  • -

#7 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 221
  • View blog
  • Posts: 1,478
  • Joined: 16-March 11

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 10:29 AM

I want to state for those who think Mysql and SQL are the same, they are not.
Was This Post Helpful? 0
  • +
  • -

#8 les1  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 10-February 12

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 11:46 PM

View PostnK0de, on 17 March 2012 - 10:24 AM, said:

Please be kind enough to share your solution here. It would help someone in the future who wants to do the same.

I'm new to MySQL myself. It would be useful to know how to do it without using commands.



Okay. To anyone who has the same problem here's the code

FOR BACKUP:
Process.Start("[PATH WHERE YOU CAN FIND THE MySQLdump.exe]", " -u [USERNAME] -p[YOUR PASSWORD] [DATABASE THAT YOU WANT TO BACKUP] -r ""[PATH WHERE YOU WANT TO SAVE YOUR BACKUP]""")


Example
Process.Start("C:\xampp\mysql\bin\mysqldump.exe", " -u root -pPASSWORD test -r ""C:\xampp\mysql\database backup\backup.sql""")



FOR RESTORE:
Dim myProcess As New Process()
            myProcess.StartInfo.FileName = "cmd.exe"
            myProcess.StartInfo.UseShellExecute = False
            myProcess.StartInfo.WorkingDirectory = "C:\xampp\mysql\bin\"
            myProcess.StartInfo.RedirectStandardInput = True
            myProcess.StartInfo.RedirectStandardOutput = True
            myProcess.Start()
            Dim myStreamWriter As StreamWriter = myProcess.StandardInput
            Dim mystreamreader As StreamReader = myProcess.StandardOutput
            myStreamWriter.WriteLine("mysql -u [USERNAME] -p[YOUR PASSWORD] [DATABASE] < [PATH WHERE YOUR BACKUP LOCATED]")
            myStreamWriter.Close()
            myProcess.WaitForExit()
            myProcess.Close()


Example
Dim myProcess As New Process()
            myProcess.StartInfo.FileName = "cmd.exe"
            myProcess.StartInfo.UseShellExecute = False
            myProcess.StartInfo.WorkingDirectory = "C:\xampp\mysql\bin\"
            myProcess.StartInfo.RedirectStandardInput = True
            myProcess.StartInfo.RedirectStandardOutput = True
            myProcess.Start()
            Dim myStreamWriter As StreamWriter = myProcess.StandardInput
            Dim mystreamreader As StreamReader = myProcess.StandardOutput
            myStreamWriter.WriteLine("mysql -u root -pPASSWORD test < C:\xampp\mysql\database backup\backup.sql")
            myStreamWriter.Close()
            myProcess.WaitForExit()
            myProcess.Close()


I hope it helps ^^


I own nothing, I just found it by searching. Credit to original coder. :surrender:
Was This Post Helpful? 1
  • +
  • -

#9 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 204
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 11:49 PM

Thanks. :)
Was This Post Helpful? 0
  • +
  • -

#10 les1  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 10-February 12

Re: How to backup and restore mysql database using vb.net

Posted 17 March 2012 - 11:54 PM

You're welcome :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1