Welcome to MSDN Blogs Sign in | Join | Help

Connecting to MySQL from SSIS

Update:  See this follow-up post on writing data to MySQL.

I've recently seen a bunch of questions about connecting to MySQL from SSIS, so I thought I'd give it a try. Our connectivity wiki currently doesn't have anything about MySQL on it, but I'll try and get it update with this information.

My overall findings was that while there were quirks, both the ODBC and ADO.Net drivers that I tried worked fine. Both drivers work with the ADO.Net Source (DataReader Source in 2005), and ADO.Net destination (Katmai only). For ease of use and install, I'd recommend using the ADO.Net driver.

The screen shots in this post were taken with an early February CTP Katmai build.

ODBC - Connector/ODBC 5.1, Connector/ODBC 3.51

Our connectivity white paper briefly mentions using MySQL's ODBC drivers, so they were the first thing I tried. I didn't so extensive testing, but it looked like both the 5.1 (beta) and 3.51 (release) drivers worked the same when connecting to my MySQL 5.0.45 server.

To use an ODBC connection in an SSIS data flow, create a new ADO.NET Connection and select the "Odbc Data Provider".

image

The ODBC drivers didn't show on the list of choices in the windows "ODBC Data Source Administrator" dialog (I'm running Vista x64... not sure if I have to do something special to make them show), so I entered the connection string directly instead of using a DSN.

DRIVER={MySQL ODBC 5.1 Driver};SERVER=<host>;DATABASE=mydb;UID=root
DRIVER={MySQL ODBC 3.51 Driver};SERVER=<host>;DATABASE=mydb;UID=root

image

Once the connection is created, you can pull data from the database using an ADO.Net Source in the data flow (DataReader Source in 2005). Trying to retrieve the tables using the drop down list resulted in an error:

image

Switching to use a SQL query instead, and that worked just fine. I was able to pull back both the correct metadata, with one small problem - the varchar(50) columns came back with a length of 51. This resulted in some warnings, but the package ran correctly.

I should note that the first time I ran the package, I got the classic 64bit problem -

[ADO NET Source [1]] Error: System.Data.Odbc.OdbcException: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
   at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSConnectionManager100.AcquireConnection(Object pTransaction)
   at Microsoft.SqlServer.Dts.Pipeline.DataReaderSourceAdapter.AcquireConnections(Object transaction)
   at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostAcquireConnections(IDTSManagedComponentWrapper100 wrapper, Object transaction)

I had only installed the 32bit drivers on my machine (it doesn't look like they will let you install both 32bit and 64bit MySQL drivers at the same time). Switching the Run64BitRuntime project setting to False fixed the issue.

ADO.NET - Connector/Net 5.1

The provider was very easy to install. Setting up the connection manager was fairly straightforward, although I had some weirdness when setting the "Persist Security Info" value to true. For some reason it didn't save my login information the first time I hit OK - I had to open it and save it again.

image

Like we saw with the ODBC drivers, the tables and views didn't show up in the drop down list (I didn't get a chance to debug too deep into it, so I'm not sure if that's a problem on the SSIS side, or something about the metadata being returned by the provider).

image

I switched it to SQL query mode ("SELECT * from Customers"), and that brought back the metadata correctly.

image

The ADO.Net Destination worked fine, although I had to type in the table name as the list wasn't auto-populated, and I didn't run into any problems with the simple data set I was using. The transfer speed seemed reasonable as well. Eventually I'd like to benchmark various ADO.Net providers, but I'll leave that as a topic for another post.

----

NOTE: I did this investigation about a month ago, but didn't have time to complete the write up. It looks like Connector/Net 5.2 has been released since then. It has some interesting features (including VS 2008 integration), so I'll give it a try and update the post if anything has changed.

Published Monday, March 03, 2008 10:23 PM by mmasson
Filed under: ,

Comments

# re: Connecting to MySQL from SSIS

Am I the only one that can't get this working? I see loads and loads of other folks that can't seem to write data to MySQL. I can see the schema of the MySQL DB (I am using .NET Connector 5.2.5) but cannot write even a single row to the destination DB.

Did you test an Insert or Update against a MySQL database? If so, what is the sql_mode of your MySQL DB?

Monday, January 05, 2009 1:19 PM by edub71

# Writing to a MySQL database from SSIS

A couple of users reported being unable to use the ADO.NET destination to insert data into their mysql

Wednesday, January 07, 2009 8:32 PM by SSIS Team Blog

# re: Connecting to MySQL from SSIS

Hi,

I am unable to connect My SQL server by following above mention steps in blog. Can u provide me more step or sample SSIS package to transfer data from SQL TO MY-SQL Server.

currently I am unable to get ADO.Net Source code Editor.

Please Help Me.

Thank You

Vaibhav

Tuesday, February 24, 2009 6:44 AM by vaiwar

# re: Connecting to MySQL from SSIS

Hello,

Are you using SQL 2005 or SQL 2008?

The ADO.NET Source was added in 2008. 2005 has something similar - the DataReader Source, but it doesn't have the same UI that I show in this blog.

~Matt

Tuesday, February 24, 2009 12:40 PM by mmasson

# re: Connecting to MySQL from SSIS

Hi Matt,

I am getting following error message in SQL 2008 while transfering data from MS-SQL to My-SQL Server

Error description:

1)[ADO NET Destination [231]] Error: An exception has occurred during data insertion, the message returned from the provider is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"BookID") VALUES (p1)' at line 1

2)[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "ADO NET Destination" (231) failed with error code 0xC020844B while processing input "ADO NET Destination Input" (234). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure.

Please help me.

Thank You

Vaibhav

Wednesday, February 25, 2009 9:01 AM by vaiwar

# re: Connecting to MySQL from SSIS

Please see the follow-up post I made about writing data to MySQL.

http://blogs.msdn.com/mattm/archive/2009/01/07/writing-to-a-mysql-database-from-ssis.aspx

You should be able to find the work around for your issue there.

Wednesday, February 25, 2009 12:54 PM by mmasson

# re: Connecting to MySQL from SSIS

Hi Matt,

Thank you very much.

I am able to connect My-SQL and successfully transfer my data from SQL to My-SQL

Friday, February 27, 2009 2:19 AM by vaiwar

# How do I do UPDATE and DELETE if I don’t have an OLEDB provider?

A comment on my post about writing to a MySQL database inspired me to put together this post about how

Monday, March 02, 2009 1:45 PM by SSIS Team Blog

# re: Connecting to MySQL from SSIS

Hi Matt,

I am trying to transfer data from MySQL to SQL.

I got as far as being able to see the "Available External Columns".

After selecting (drag&drop) the SQL Server Destination, I don't see any of those "Available External Columns" from the ADO.Net source.  I guess I don't know how to select the input columns.  Please help.  Thanks.

I said "transfer" earlier but it's more of a convert than transfer.  I want to learn more about SSIS & MySQL2SQL.

Bernie

Tuesday, June 02, 2009 2:15 PM by berniesu
Anonymous comments are disabled
 
Page view tracker