Using MySQL with the Database Connectivity Toolkit on Windows
Primary Software: LabVIEW Toolkits>>Database Connectivity Toolset
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Problem: How do I connect to a MySQL database using the LabVIEW Database Connectivity Toolkit from my Windows machine?
Solution: There are several ways to connect to a MySQL database from LabVIEW using the Database Connectivity Toolkit. This article outlines how to use the ODBC tools provided by
Mysql.com. This article also assumes that you either have a MySQL database installed and running on your current computer or another computer accessible through the network.
- Download the ODBC server MSI from mysql.com.
- Install the server on your PC
- Navigate to Start»Settings»Control Panel»Administrative Tools»Data Sources (ODBC)
- Click the Drivers tab and ensure that MySQL is listed
- Go back to the User DSN tab, click Add, and select MySQL

- A new window will popup allowing you to enter in your connection information to your MySQL server. The default port number is 3306. You can enter localhost as the server name if you have it installed on the computer you're currently working on.

- In LabVIEW, put a DB Tools Open Connection VI on the block diagram and wire a true constant into the prompt input.
- Run the VI
- A prompt will come up asking for your connection. In this dialog box select the Connection tab, and from the Use data source name drop down list select the server connection you've just created.
At this point, your application will error out, but that's because you did not do anything with the connection. In your application, be sure to use a DB Tools Close Connection VI at the end of your program or database access. You can specify the path to your DSN file by creating a control wired to the source terminal on the DB Open Tools VI and setting the prompt value to false.
For further help, see the
Database Connectivity User's Manual.
Related Links: MySQL Connector ODBC Product Manuals: LabVIEW Database Connectivity Toolkit Manuals (June 2008)
Attachments:
- odbc.jpg
- dsn.jpg
- connector.jpg
Report Date: 10/17/2006
Last Updated: 07/24/2009
Document ID: 42GBLU00