Connecting to MySQL
Connecting to MySQL
Watch the videoOn this page we'll demonstrate how to connect Ignition to MySQL.
MariaDB Connections to MySQL Databases​
Ignition can use the built-in MariaDB driver to connect to MySQL 5.7 and prior databases. This circumvents the need to manually provide a JAR file to the MySQL JDBC Driver configuration on the Gateway.
Ignition version 8.1.2 includes a MariaDB driver that can connect to MySQL 8 databases. Note that upgrading Ignition does not replace existing JDBC drivers. See the JDBC Drivers and Translators page for more information.
MySQL Connector/J Connections to MySQL Databases​
Should you choose to to connect to a MySQL database using the official MySQL JDBC Driver, you will need to install the driver. New Ignition installations do not have the driver (a JAR file), so you will have to acquire the file yourself. See the JDBC Drivers and Translators page for more details on obtaining the required file.
Once acquired, you can follow the steps for Upgrading a JDBC Driver. Once the JAR file has been provided, you can follow the steps listed on this page to configure a connection between Ignition and MySQL.
Connect Ignition to MySQL Database​
On the Gateway Webpage, go to the Config section.
Scroll down to Databases > Connections.
Click on Create new Database Connection....
Select the MySQL driver and click Next. You may need to install a JDBC driver for MySQL.
noteAlternatively, you may select the MariaDB driver, and use that to connect to MySQL. See the MariaDB Connections to MySQL Databases section above.
On the New Database Connection page, enter the following information:
Name: MySQL (use a meaningful name such as MySQL)
Connect URL: jdbc:mysql://localhost:3306/test (By default, MySQL creates an empty database called test)
As you see in the example above, MySQL uses the following Connect URL format: jdbc:mysqldb://hostaddress:3306/database
Where hostaddress is the address of the machine with MySQL installed, for example: localhost, 192.168.1.1, db-server, etc. Database specifies the database schema the connection will target. The connection will target one schema (a collection of tables and other objects) in the database.
To configure the connection, Ignition needs credentials to connect to MySQL. The Username and Password fields are where you provide credentials for a user that Ignition will use to authenticate against the database. The user should be able to do the following:
- Create and drop tables within the schema
- Alter tables within the schema
- Insert, update, select, and delete rows from tables in the schema
- Create, alter, and execute stored procedures within the schema
After entering a username and password, click on Create New Database Connection at the bottom of the form. Your connection is now created and the Database Connections page is displayed showing the Status of your connection as Valid.
To display the details about the status of your database connection, click on the Database Connection Status link in the page note. This will display any errors if your status is Faulted, in this example it shows the status as being Valid.