This topic explains how to configure a MySQL database as an
external data source. We strongly recommend using MySQL 5.6 or higher; the MySQL JDBC driver that ships with LabKey Server (Connector/J 8.0) claims compatibility "with all MySQL versions starting with MySQL 5.6", so older server versions may not work correctly.
Configure the MySQL Data Source
Add a <Resource> element, to your installation's
labkey.xml configuration file. Use the configuration template below as a starting point. Replace USERNAME and PASSWORD with the correct credentials. If you are running LabKey Server against a remote installation of MySQL, change the url attribute to point to the remote server.
If you will be connecting to more than one data source, be sure that all have unique
name parameters, i.e. mySqlDataSource1, mySqlDataSource2, or similar. This value will be used whenever you connect an
external schema to this datasource so it must be unambiguous.
<Resource name="jdbc/mySqlDataSource" auth="Container"
type="javax.sql.DataSource"
username="USERNAME"
password="PASSWORD"
driverClassName="com.mysql.cj.jdbc.Driver"
url="jdbc:mysql://localhost:3306/?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL"
maxTotal="15"
maxIdle="7"
accessToUnderlyingConnectionAllowed="true"
validationQuery="/* ping */"
/>
Note: the "zeroDataTimeBehavior=CONVERT_TO_NULL" parameter on the url above converts MySQL's special representation of invalid dates ("00-00-0000") into null. See the MySQL documentation for other options.
Define a New Schema
Now define a new schema from the MySQL data source. For details see
Set Up an External Schema.
Related Topics