Logging TestStand Results to a MySQL Database Tutorial

Updated Mar 5, 2024



  • TestStand
  • Database Connectivity Toolkit
  • LabVIEW

I want to log results from TestStand to a MySQL database. What software do I need and what are the settings and steps during installation of the MySQL adapter?

After following the instructions in the five sections of this document, you will have created a MySQL database and TestStand configured for logging results. Once you have completed all of the steps in this document, execute a test sequence and then use the Database Viewer, to view the results that have been logged to the MySQL database.
Note: These instructions assume MySQL Server 5.6MyODBC 5.3 Driver and TestStand 2013 are installed.
  1.  Installation
    1. Download MySQL Installer ​.
    2. Install MySQL Tools as Developer. Open Database Connectivity (ODBC) / Connector must be correctly installed, otherwise download it from MySQL and install it separately.
Note: When using Windows 64bit install the ODBC Driver for 64bit first, reboot the system and install the 32 bit driver afterwards..
  1. Set a password for your root.
  1. Creating the Database and User
    1. Open MySQL Workbench:  Start>>All Programs>>MySQL>> MySQL Workbench 6.1 CE.
    2. Manage a new connection: Database>>Manage Connections and press "New".
    3. You should see the following screen:
    4. Open new connection by double clicking it.
    5. Create new database by clicking on the button Create new Schema in the connected Server and name it, e.g. TestStand_MySQL_DB. Press Apply.
    6. Select Users and Privileges from the upper left-hand pane.
    7. Select Add Account from the bottom of the window.
    8. Fill in the text for MySQL User and Password
    9. After filling in the fields shown, click Apply changes.
    10. Click on the Schema Privileges Tab.
    11. Click on Add Entry, and you should see:
    12. Select TestStand_MySQL_DB and press OK. Add now the wanted privileges for this database.
      (for this tutorial: use Select All)
    13. Press Apply.
    14. Restart service for the changes to take effect (Click on Stop Service and then Start Service).
  2. ODBC Data Source Administrator:
    1. Use the ODBC Data Source Administrator to create a Data Source Name (DSN) and the corresponding database: Start>>Settings>>Control Panel>>Administrative Tools.
    2. Double-click the ODBC icon Data Sources (ODBC) to open the ODBC Data Source Administrator dialog box.
    3. Select the System DSN tab when you want data source visible to all users on this machine.
      Select the User DSN tab when you want data source visible only for this users.
    4. Click Add and select MySQL ODBC Driver from the list:
      1. If MySQL ODBC Driver does not exist, install Connector/ODBC (Select the correct bits according to your application).
    5. Click Finish.
    6. Fill in the dialog box shown below with a unique Data Source Name of your choosing. teststand2 is used in this example.
    7. Type in the user name and password for the user created above. Both are case-sensitive.
    8. Select the database created above: teststand_mysql_db.
    9. Click Test to make sure the connection works. You should see the following message: Success; Connection was made!
  3. ​TestStand Database Options:
    1. Use the TestStand Sequence Editor to configure TestStand to use the newly created Data Source:
      : Open the TestStand Sequence Editor, and select Configure>>Result Processing
    2. Add new Database Logging and Enable Database Logging by selecting the corresponding check box.
    3. Click on Database Option >> Data Link tab. Use this tab to create a data link for TestStand.
    4. Select MySQL from the drop down list box for Database Management System and press Build.
    5. Click on the Provider Tab of the Data Link Properties dialog box.
    6. Select Microsoft OLE DB Provider for ODBC Drivers as shown below:
    7. Click Next.
    8. Select the Data Source Name created in ODBC Data Source Administrator under the System
      DSN/System Data Sources
      . In this example MySQL_DB_For_TestStand is used.
    9. Type in the User Name and password, and then click Test Connection. 
    10. Click the OK button two times to close the Data Link Properties dialog box.
    11. Click the Schemas Tab and enable the MySQL Insert (NI) schema.
    12. Click OK button to close the Database Options dialog box.
  4. Creating Database Tables
    1. Use the Database Viewer built into TestStand to view data, edit database table properties, and
      execute SQL commands on the database. Open the Database Viewer by selecting Configure>>Report Processing>> (Database to view) >> Database Options  
    2. Select View Data from the Data Link tab in the Database Options dialog box
    3. Select File>>Open and select SQL (*.sql) files from the Files of Type field at the bottom of the
      dialog box.
    4. Open MySQL Create Insert Result Tables.sql from the %TestStand%/Components/
    5. Press the Execute SQL Commands button (green arrow) to execute the commands.
    6. Review the results of the SQL commands in the SQL History control of the Execute SQL window. 
    7. Close the Execute SQL window.
    8. The created tables can now be viewed in the Database Viewer. Select Window>>Refresh to verify that the tables were created successfully
    9. Run Your Program or an Example to and check if data is logged to database

Additional Information

If you receive this error message when trying to access the mySQL database using the Database Viewer:

And your Connection String Expression looks like this:

Try to change the Database String Expression to:
"Driver={MySQL ODBC <version> ANSI Driver};Server=<server IP>;Database=<database name>;User=<user name>;password=<password>"
<version> is replaced by the mySQL driver version.
<server IP> is replaced by the IP address of your mySQL server.
<database name> is replaced by the name of the database on the database server.
<user name> is replaced by your user name to log into the database server and
<password> is replaced by your password for the database server account.
The result should look like this:

Afterwards, verify that result recording still works and you can view the data in the database by clicking View Data.

Next Steps

The Using Databases and Reports with TestStand video provides more guidance on using databases and reports in TestStand.