Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

MySQL Server problem

Monsters

Recruit
Basic Member
Messages
12
Reaction score
3
Points
18
Posible ba na makopya yung table from one mysql server to another mysql server? Kung posible, how? VB2012 gamit ko and MySQL workbench as back end. Salamat sa mga sasagot.:-)
 
Bat di mo na lang lods e restore ung db dun sa destination server
Gagamit kasi ako paps ng 2 computers na parehong may MySQL Server installed. Then meron lang akong kailangan na table na ika-copy ko sa another server. Kung online server sana e walang nang problem. Kaya lang mahal kasi magmaintain ng online server. Ano kaya mas maganda?
 
chief, natry mo ba ung command na to dun sa old mysql source mo?

create backup table structure + data from old mysql: mysqldump -u <source_username> -p <source_database_name> <source_table_name> > table_backup.sql
restore table structure + data into new mysql : mysql -u <target_username> -p <target_database_name> < table_backup.sql

Kung directly naman sa mysql workbench select mo nlang.
Server > Data Export > check mo ung target table > tas select mo "Export to Self-Contained File" > Start Export

Restore:
Server> Data Import > tas select mo "Import to Self-Contained File" > Start Import.
 
Last edited:
chief, natry mo ba ung command na to dun sa old mysql source mo?

create backup table structure + data from old mysql: mysqldump -u <source_username> -p <source_database_name> <source_table_name> > table_backup.sql
restore table structure + data into new mysql : mysql -u <target_username> -p <target_database_name> < table_backup.sql

Kung directly naman sa mysql workbench select mo nlang.
Server > Data Export > check mo ung target table > tas select mo "Export to Self-Contained File" > Start Export

Restore:
Server> Data Import > tas select mo "Import to Self-Contained File" > Start Import.
Gusto ko sana eh diretsong command galing sa program ng vb.net. ide-deploy ko kasi yan. *giggle*
 
ito chief try mo.

Imports MySql.Data.MySqlClient
Imports System.Data

Module MainModule
Sub Main()
Dim sourceConnStr As String = "Server=oldServer;Database=oldDB;Uid=username;Pwd=password;"
Dim destConnStr As String = "Server=newServer;Database=newDB;Uid=username;Pwd=password;"

Dim sourceConn As New MySqlConnection(sourceConnStr)
Dim destConn As New MySqlConnection(destConnStr)

Try
sourceConn.Open()
destConn.Open()

Dim tableName As String = "pangalan_ng_table"
Dim schemaQuery As String = "SHOW CREATE TABLE " & tableName
Dim schemaTable As New DataTable()

Using schemaCmd As New MySqlCommand(schemaQuery, sourceConn)
Using schemaAdapter As New MySqlDataAdapter(schemaCmd)
schemaAdapter.Fill(schemaTable)
End Using
End Using

Dim createTableQuery As String = schemaTable.Rows(0)("Create Table").ToString()

Using createTableCmd As New MySqlCommand(createTableQuery, destConn)
createTableCmd.ExecuteNonQuery()
End Using

Dim selectDataQuery As String = "SELECT * FROM " & tableName

Using selectDataCmd As New MySqlCommand(selectDataQuery, sourceConn)
Using dataReader As MySqlDataReader = selectDataCmd.ExecuteReader()
While dataReader.Read()
Dim insertQuery As String = "INSERT INTO " & tableName & " VALUES ("

For i As Integer = 0 To dataReader.FieldCount - 1
If i > 0 Then
insertQuery += ","
End If

insertQuery += "'" & dataReader.GetValue(i).ToString() & "'"
Next

insertQuery += ")"

Using insertCmd As New MySqlCommand(insertQuery, destConn)
insertCmd.ExecuteNonQuery()
End Using
End While
End Using
End Using

Console.WriteLine("Table copied successfully!")
Catch ex As Exception
Console.WriteLine("Error: " & ex.Message)
Finally
sourceConn.Close()
destConn.Close()
End Try

Console.ReadLine()
End Sub
End Module
 
Salamat Tuts. i-try ko.
Na-try ko na po sya Tuts and it's working. Meron lang konting error kapag nag-i-insert na ng data. Error sya kapag meron single qoute yung data. Ang kailangan ko na lang gawin ay mag-research on how to trap those single qoutes on data. Salamat ulit Tuts.
 
Last edited:
Back
Top Bottom