I'm thinking if it is possible to migrate a Table and its content into a new Database from an old database structure.
I just want to migrate all the datas of specific table from old database into my new database.
So far I use Import/Export function of MySQL Workbench
then save a dump as .sql then I processed it like this
But I notice that, that codes I used will not work if my new database name is not the same as the old database name, if not my code create a new db which is named as the old db where table imported.Code:Private Sub btnImports_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImports.Click Dim path As String Dim ofd As New OpenFileDialog ofd.InitialDirectory = "C:\\" ofd.Filter = "SQL Sripts (*.sql)|*.sql" If ofd.ShowDialog() = DialogResult.OK Then path = ofd.FileName Dim myProcess As New Process() myProcess.StartInfo.FileName = "cmd.exe" myProcess.StartInfo.UseShellExecute = False myProcess.StartInfo.WorkingDirectory = "C:\Program Files\MySQL\MySQL Server 5.5\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 -p < " & path) myStreamWriter.Close() myProcess.WaitForExit() myProcess.Close() MessageBox.Show("Import Done!") End If End Sub
The .sql file is the dump of table using MySQL Workbench


Reply With Quote
