SQL Server to MySQL data transfer

浪尽此生 提交于 2019-12-03 06:39:54
Todd Ellermann

I used the jdbc-odbc bridge in Java to do just this in the past, but performance through ODBC is not great. I would suggest looking at something like http://jtds.sourceforge.net/ which is a pure Java driver that you can drop into a simple Groovy script like the following:

import groovy.sql.Sql
sql = Sql.newInstance( 'jdbc:jtds:sqlserver://serverName/dbName-CLASS;domain=domainName',     
'username', 'password', 'net.sourceforge.jtds.jdbc.Driver' )
sql.eachRow( 'select * from tableName' ) { 
  println "$it.id -- ${it.firstName} --" 
  // probably write to mysql connection here or write to file, compress, transfer, load
}

The following performance numbers give you a feel for how it might perform: http://jtds.sourceforge.net/benchTest.html

You may find some performance advantages to dumping data to a mysql dumpfile format and using mysql loaddata instead of writing row by row. MySQL has some significant performance improvements for large data sets if you load infile's and doing things like atomic table swaps.

We use something like this to quickly load large datafiles into mysql from one system to another e.g. This is the fastest mechanism to load data into mysql. But real time row by row might be a simple loop to do in groovy + some table to keep track of what row had been moved.

mysql> select * from table into outfile 'tablename.dat';  

shell> myisamchk --keys-used=0 -rq '/data/mysql/schema_name/tablename'

mysql> load data infile 'tablename.dat' into table tablename;

shell> myisamchk -rq /data/mysql/schema_name/tablename

mysql> flush tables;
mysql> exit;

shell> rm tablename.dat
djhaskin987

The best way I have found to transfer SQL data (if you have the space) is a SQL dump in one language and then to use a converting software tool (or perl script, both are prevalent) to convert the SQL dump from MSSQL to MySQL. See my answer to this question about what converter you may be interested in :) .

We've used the ado.net driver for mysql in ssis with quite a bit of success. Basically, install the driver on the machine with integration services installed, restart bids, and it should show up in the driver list when you create an ado.net connection manager.

As for replication, what exactly are you trying to accomplish?

If you are monitoring changes, treat it as a type 1 slowly changing dimension (data warehouse terminology, but same principal applies). Insert new records, update changed records.

If you are only interested in new records and have no plans to update previously loaded data, try an incremental load strategy. Insert records where source.id > max(destination.id).

After you've tested the package, schedule a job in the sql server agent to run the package every x minutes.

Cou can also try the following. http://kofler.info/english/mssql2mysql/

I tried this a longer time before and it worked for me. But I woudn't recommend it to you. What is the real problem, what you try to do? Don´t you get a MSSQL DB Connection, for example from Linux?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!