mysql数据库复制到另外一台电脑,将MYSQL数据库从一台计算机复制到另一台计算机...

I have a source database in one system. I want to create a target Database (with same schema as Source database) in another system in a different network (both systems are not connected in any way).

now we are creating a dump on system 1 and using a stick to copy it into system 2. But we are looking for a better solution through C#.

I have already created sqldump on system 1 and now I need help on how I can access the system 2 from system 1 to use the dump file and create a target database or should I be writing a code to be run in system 2 that in turn takes the dump of system1 database? how should I be going about with this?

I will go on further to do some database verification once the Target db is created, comparing the 2 databases and syncing the data among the two.

So I am looking for a C# solution.

any ideas?

P.S. code that creates sqldump on system 1:string constring1 = "SERVER=localhost;" + "DATABASE=;" + "UID=root;" + "PASSWORD=;" + "Convert Zero Datetime=True;" +

"Allow Zero Datetime=True";

using (MySqlConnection conn = new MySqlConnection(constring1))

{

using (MySqlCommand cmd = new MySqlCommand())

{

using (MySqlBackup mb = new MySqlBackup(cmd))

{

cmd.Connection = conn;

conn.Open();

mb.ExportInfo.AddCreateDatabase = true;

mb.ExportInfo.ExportTableStructure = true;

mb.ExportInfo.ExportRows = false;

mb.ExportToFile(file1);

}

}

}

解决方案

Option 1: By using web services.

Create a web server and host a web service at server 2.

Server 1 will send over the byte[] (byte array) to server 2 through the web service.

Option 2: By using a web page

At server 2, create a ASP.NET web page that accept a http post.

Server 1 will access the web page programmatically and upload the file.

Server 2, once the file received at the web page, ASP.NET engine will process it.

Option 3: By opening a TCP Client/Server port using C# at server 2

Create a C# Socket at server 2.

Server 1 will connect the socket then transmit the byte[] to server 2 through the socket.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值