Benchmarking MySQL with JMeter

This page describes setting up JMeter to benchmark a MySQL database using JDBC queries.

Install the JDBC Driver for MySQL

In order for JMeter to access a MySQL database as a client, it needs a JDBC database driver. For MySQL this is called MySQL Connector/J and is available at http://www.mysql.com/products/connector/j/. Download Connector/J and unzip the file. This will produce a directory containing the Connector/J files. In this directory you will find the connector jar file (mysql-connector-java-version-ga-bin.jar). Copy this file to the JMeter lib directory.

Configure the JDBC Sampler

Start JMeter and under the test plan node create a Thread Group, and under that create a JDBC Request Sampler.

For MySQL the Driver Class should be com.mysql.jdbc.Driver.

The JDBC URL is of this form: jdbc:mysql://server/databaseName?user=username&password=password

The SQL Query String is the SQL Query you want to benchmark. Start with something simple: create a table in the test database and execute a 'desc' query against it.

Try It Out

Add a View Results in Table Listener to the Thread Group. When ready, start the JMeter test run. After a few seconds, sample results should start to appear in this table. Ensure that the checkbox in the Success? column is checked. If it is, your query returned okay. You can now make test plans using JDBC queries much as you would make tests for a website.

Happy benchmarking!

  • No labels