如何在VB.Net中创建mysql数据库的数据库备份?
最佳答案
您可以使用MySqlBackup.NET,它是mysqldump的替代品。
官方网站和文档>https://github.com/MySqlBackupNET/MySqlBackup.Net
示例:
备份MySql数据库
Dim conn As MySqlConnection = New MySqlConnection(constr)
Dim cmd As MySqlCommand = New MySqlCommand
cmd.Connection = conn
conn.Open
Dim mb As MySqlBackup = New MySqlBackup(cmd)
mb.ExportToFile("C:\backup.sql")
conn.Close
还原MySql数据库
Dim conn As MySqlConnection = New MySqlConnection(constr)
Dim cmd As MySqlCommand = New MySqlCommand
cmd.Connection = conn
conn.Open
Dim mb As MySqlBackup = New MySqlBackup(cmd)
mb.ImportFromFile("C:\backup.sql")
conn.Close
我是这个项目的作者之一。