Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have setup 2 pc in my office as for testing before it deploy to the client location. This system is needed to backup MySQL database and import to the PC which located within LAN. PC1 successfully load with new database, but PC2 failed when import it. Please see my code below.

VB
Private Function StartRestore(ByVal i As Integer) As Boolean
    Dim kiosk_address As String = arr_sendkiosk.Item(i)
    Try
        kiosk_address = kiosk_address.Remove(0, 2)
        If objConn.IsNetworkAvailable(kiosk_address) Then
            AppendPositive("Reponse alive from " & kiosk_address & vbCrLf)
        End If
        If Not (isSchemaExist(kiosk_address)) Then
            CreateNewSchema(kiosk_address)
        Else
            DropExistedSchema(kiosk_address)
            CreateNewSchema(kiosk_address)
        End If
        Dim constring As String = "server=" & kiosk_address & ";user=myAdmin;pwd=" & udt_server.strUserPwd & ";database=" & udt_server.strDBName & ";port=3306;"
        AppendPositive("Start restoring database." & vbCrLf)
        Using conn As New MySqlConnection(constring)
            Using cmd As New MySqlCommand()
                Using mb As New MySqlBackup(cmd)
                    cmd.Connection = conn
                    conn.Open()
                    Try
                        mb.ImportFromFile(sqlpath)
                        AppendPositive("Restore success for " & kiosk_address & vbCrLf)
                        conn.Close()
                        Return True
                    Catch ex As Exception
                        conn.Close()
                        AppendNegative("Restore failed for " & kiosk_address & vbCrLf)
                        AppendNegative("Exception:-" & ex.Message & vbCrLf)
                        Return False
                    End Try
                End Using
            End Using
        End Using
    Catch ex As Exception
        AppendNegative("Unable to restore data to kiosk.Ex-" & ex.Message & vbCrLf)
        Return False
    End Try
End Function


The PC1 is load with new but PC2 not. Is there any setting or task to do for this?
I already create new user privileges in PC2 as below:-

CSS
CREATE USER 'myAdmin'@'%' IDENTIFIED BY 'myAdmin321';

GRANT ALL PRIVILEGES ON *.* TO 'myAdmin'@'%';

FLUSH PRIVILEGES;
Posted
Comments
Garth J Lancaster 9-Feb-15 2:04am    
I think you need to elaborate on "but PC2 failed when import it" a bit more - what does that mean ? were there any errors ? have you checked the MySQL log ?

Can you see what I mean ? Its hard for someone 'out here' who cant see your machine and what's happening on it ...

Having a quick look at your code, you seem to have accounted for the network/database connectivity, that means the issue (could) lie elsewhere... I'd be looking at the MySQL logs
Luiey Ichigo 9-Feb-15 3:06am    
Where can I find the MySQL log? Where should I find it? In sender PC or retrieve PC? It happen here: mb.ImportFromFile(sqlpath). I already check back the Inbound Rules in Firewall and I check all rules(Private,Domain and Public). But another thing occur, regarding timeout. What should I for timeout? Should I insert the timeout on connstring or commandtimeout(MySQLCommand) in VB code before sending the file?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900