sql 同步 mysql,Sql Server和Mysql Server之间的同步

I have 2 big tables in sql server that i need to sync to mysql.

now, i need that as an ongoing process.

the tables are 1 GB each and getting new/update/delete row every 0.1 second.

Can you recommend me a tool that can do it that is not resource expensive.

you can offer OPEN SOURCE and commercial as well

Thanks

解决方案

You could create a linked server instance in SQL Server, pointing to the MySQL instance. This article gives the step-by-step process. Once that is in place, providing you grant the MySQL user you connect on behalf of proper permissions, you can write to the MySQL instance as you like. So you could easily update stored procedures to do an additional step to insert records into MySQL.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Windows.Forms; using System.Data.SqlClient; using System.Text; using MySql.Data; using MySql.Data.MySqlClient; //本程序的功能是实时从mysql中读取一条记录中的一个字段,插入到sqlserver 中,经过长时间的运行,基本无错了, 而这数据同步,目前没有实时性强的软件,至少1分钟,太久了,自己写了一个, //可以自己设置同步时间,字符连接串等,给了源码,而且对程序进行了很多优化 容错性很强,懂点程序的 就可以直接修改源码 就可以用了。由于没有时间按做界面,只能自己修改了,不过已经很稳定了,为了给大家提供点方便,免得还去查大量的资料。 namespace tool { public partial class Form1 : Form { public string mysql_Conn = "Database='cmccbbs';Data Source='211.139.22.124';UserId='cmcc';Password='CMCC2014cmcc2014';charset='utf8';pooling=true"; public string mysql_sql = "select max(id) from pre_sms_tempsend"; // public string sql_server_Conn = "Data Source=lei; DataBase=test; User=sa;PWD=123456"; 211.222.229.124 public string id, phone, verify, last_id; SqlConnection my_sql_con; MySqlConnection con; MySqlCommand cmd; DataSet ds; public string sql_server_Conn = "Data Source=222.85.144.112,14444; DataBase=DB_CustomSMS; User=sms;PWD=sms2014"; // public string sql_sql = "select max(id) from pre_sms_tempsend"; MySqlDataAdapter md; public int ii = 0; public Form1() { InitializeComponent(); timer1.Interval = 1000; //连接mysql con = new MySql.Data.MySqlClient.MySqlConnection(mysql_Conn); con.Open(); cmd = new MySqlCommand("select * from pre_sms_tempsend order by id desc limit 1", con); cmd.Connection = con; md = new MySqlDataAdapter(); ds = new DataSet(); //这样做避免一直new,导致内存泄露 } private void button1_Click(object sender, EventArgs e) { if (button1.Text == "start") { timer1.Enabled = true; button1.Text = "stop"; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值