HOWTO: Connect to MySQL in SSIS
In: Google|SSIS
Written by: Taylor Gerring
4 Jun 2009 While Microsoft provided connectors for Oracle, Teradata, and SAP BI for SSIS 2008, there are many other database systems left out of the mix. Fortunately, SSIS is exceptionally flexible in connecting to various data sources and allows other vendors to provide native support. The MySQL team did just that with Connector/NET 6.0, their ADO.NET provider. This tool allows us to use the the ADO.NET connections in SQL Server Integration Services to easily connect to MySQL. This is a walk through on how to connect to MySQL with SSIS 2005 utilizing the Connector/NET 6.0 ADO.NET provider.
- Download and install MySQL Connector/NET 6.0
- Start a new Integration Services project in BIDS
- Right-click in Connection Managers and create a new ADO.NET Connection

- In the Provider dropdown, expand .Net Providers and select MySQL Data Provider. Press "OK"

- Fill out the Server name, User name, Password and select the database name for the target MySQL server. Be sure to test the connection and press “OK”

- Rename the connection to “MySQLDB”

- Open up the Toolbox and drag a Data Flow Task from the toolbox onto the Control Flow surface

Add Dataflow Task
- Double-click the Data Flow Task to switch to the Data Flow view
- Create a new variable, “MySQLResult” with the Data Type of Object. We will be using this as the final destination for the data, so we don’t need to connect to a file or database to store the data from this test

MySQLResult Variable
- Drag a new DataReader Source component onto the Data Flow surface

Add DataReader Source
- Double-click the DataReader Source to open the Advanced Editor. On the Connection Managers tab, select the previously-created MySQLDB connection

DataReader Source Connection Managers
- Switch to the Component Properties tab and enter the SQL query in the SqlCommand property. Note that the query must be compatible with MySQL syntax, not SQL Server.

DataReader Source Component Properties
- Switch to the Column Mappings tab to verify that the query is successful and the all the columns were pulled from the database. When done, press “OK”.

DataReader Source Column Mappings
- Create a new Recordset Destination by dragging it from the toolbox to the Data Flow surface

Add Recordset Destination
- Drag the green Data Flow Path from DataReader Source to Recordset Destination, so they connect

Connect Source to Destination
- Double-click the Recordset Destination to open its Advanced Editor
- Under Custom Properties, select the dropdown for VariableName and select the variable we created before, User::MySQLResult

Recordset Destination Component Properties
- Switch to the Input Columns tab and select those columns that you want stored in the Recordset Destination. When complete, click “OK”

Recordset Destination Input Columns
- Right-click the green Data Flow Path and choose “Data Viewers…”

Data Flow Path Data Viewers
- Select “Data Viewers” from the left pane and click the “Add…” button

Data Flow Path Editor
- Under the General tab, select Grid and press “OK”

Configure Data Viewer
- Run the package
- If you’ve done everything correctly, you should see a Data Reader Output Data Viewer window pop up with the contents of the query we specified earlier.

Data Viewer Output
SQL Server Integration Services makes connecting to other systems very easy. The MySQL ADO.NET provider works well, but requires more configuration than a native Source component.
8 Responses to HOWTO: Connect to MySQL in SSIS
cesar
September 29th, 2009 at 12:57 pm
so then ?? how to use that dataGrid ??
Taylor Gerring
September 29th, 2009 at 1:02 pm
@cesar
The Data Viewer is just a way to visualize the data – you’re not supposed to extract data from it.
What you probably want is an OLE DB Destination or Flat File Destination instead of the Recordset Destination to permanently store the data somewhere.
timmy
November 10th, 2009 at 3:46 pm
What is BIDS??? (step #2)
Taylor Gerring
November 10th, 2009 at 3:50 pm
BIDS = SQL Server Business Intelligence Development Studio
Bernard
November 19th, 2009 at 10:45 pm
I don’t seem to have the DataReader Source in my toolbox, only the destination. Even if reset the toolbox it doesn’t seem to appear.
Has this option been removed from 2008??
Thanks,
Vincent Chang
February 11th, 2010 at 8:35 pm
Well done! Very Clear
Ting
February 16th, 2010 at 10:28 am
Hi,
This is a great article to introduce the mySQL in SSIS. I found it to be very helpful.
However, I am having trouble trying to figure out how to use this mySQL ADO in the Data Transformation section inside the Data Flow?
Basically, based on the result of a ConditionalSplit, it will either retrieve data from mySQL or doing something else.
I was able to retrieve data using this connector as the Source or Destination, but not in the Transaformation.
Any suggestion?
TIA,
Ting
shiva ramani
July 29th, 2010 at 6:54 pm
good instruction. How to push data to MySQL from SQL 2005