如何使用vb.net备份mysql数据库?

时间:2013-02-25 07:18:28

标签: mysql vb.net

所有这些代码都在运作...... 这是我备份的代码......

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Process.Start("C:\xampplite\mysql\bin\mysqldump.exe", " -u root -p db_hrm -r ""C:\Users\Rodmar\Desktop\Desktop.sql""")

End Sub

这是我恢复中的代码

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    Dim myProcess As New Process()
    myProcess.StartInfo.FileName = "cmd.exe"
    myProcess.StartInfo.UseShellExecute = False
    myProcess.StartInfo.WorkingDirectory = "C:\xampplite\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.exe -u root -p db_hrm < C:\Users\Rodmar\Desktop\Desktop.sql")
    myStreamWriter.Close()
    myProcess.WaitForExit()
    myProcess.Close()
    'Process.Start("C:\porgram files\mysql\bin\mysql.exe", "-u username -p password --database=dbname > -r ""C:\back.sql""")

End Sub

问题是如何备份数据库并选择要保存它的文件位置。以及如何将其恢复到我保存数据库的位置。

0 个答案:

没有答案