Results 1 to 2 of 2

Thread: How to migrate Table Data only into a new Database (MySQL)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    310

    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
    VB 6.0 = "Self-Study" Then
    vb.NET = "Self-Study" Then
    C# = 'on going study.....

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width