How to migrate Table Data only into a new Database (MySQL)
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
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
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.
The .sql file is the dump of table using MySQL Workbench
Re: How to migrate Table Data only into a new Database (MySQL)
So you load a new dataset with the values from the table in the old database then add that dataset to the new database. Or is that too obvious?