Configure the MySQL Connector
Connect SIA Connect to MySQL, configure TLS, create read and write query items, understand JSON results, and troubleshoot database errors.
The MySQL Connector connects SIA Connect to a MySQL database. Use it to run read queries on a schedule and execute SQL statements generated by mappings.
This guide explains how to create a MySQL instance, configure TLS, create read and write items, understand returned data, and resolve common connection and query errors.
Before you begin
Prepare the following information:
- The hostname or IP address of the MySQL server.
- The TCP port. MySQL normally uses port
3306. - The database name.
- A database username and password.
- The SQL queries that SIA Connect must run.
- A CA certificate if the server requires TLS.
- A client certificate and matching private key if the server requires certificate authentication.
Make sure SIA Connect can reach the database server and that the database accepts remote TCP connections.
Create a dedicated database account with only the permissions required by the configured queries. Read items should normally use an account with SELECT permission. Grant write permissions only when the application needs them.
SQL statements can change or remove database records. Test write queries against a non-production database before using them with live data.
Create a MySQL instance
- Sign in to the Edge Portal.
- Open Workspace > Instances.
- Select Add instance.
- Select the MySQL Connector.
- Enter a descriptive instance name.
- Enter the database server hostname or IP address in Address.
- Complete the Connector-specific parameters described below.
- Select Save.
Instance parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
| Address | Yes | None | Hostname or IP address of the MySQL server. |
| Username | Yes | None | Database account used for the connection. |
| Password | When required by the account | None | Password for the database account. |
| Database | Yes | None | Name of the database that contains the required tables or procedures. |
| Port | Yes | 3306 |
TCP port used by the MySQL server. |
| SSL enable | Yes | Disabled | Enables TLS and requires a CA certificate for server verification. |
| SSL cipher | No | Default (auto) | Restricts the TLS cipher when the server requires a specific supported cipher. |
| SSL CA | When TLS is enabled | None | CA certificate used to verify the MySQL server certificate. |
| SSL cert | When required by the server | None | Client certificate presented to the server for certificate authentication. |
| SSL key | When required by the server | None | Private key that matches the selected client certificate. |
Configure a TLS connection
Upload the required certificates to the MySQL Connector before configuring the instance. Assign each uploaded file to the correct category:
- CA certificate: Verifies the certificate presented by the MySQL server.
- Client certificate: Identifies SIA Connect when the database account requires a client certificate.
- Client key: Private key that matches the client certificate.
To enable TLS:
- Open the MySQL instance editor.
- Set SSL enable to Enabled.
- Select the server's CA certificate under SSL CA.
- If the server requires certificate authentication, select the matching SSL cert and SSL key.
- Keep SSL cipher set to Default (auto) unless the server administrator requires a specific cipher.
- Select Save.
The available explicit cipher selections are:
ECDHE-RSA-AES128-GCM-SHA256ECDHE-RSA-AES256-GCM-SHA384AES256-SHA
The Connector does not allow TLS to start without an SSL CA file. A client certificate and key are optional unless the MySQL server requires mutual TLS.
Understand MySQL items
Each item contains a Query default field. How the Connector uses the item depends on its read and write direction.
- Read: Runs the SQL statement entered in Query default at the item's configured polling interval.
- Write: Executes the incoming item value as a complete SQL statement. The statement normally comes from a mapping.
- Read/Write: Can run the configured read query and execute incoming SQL statements.
The Connector automatically creates a Write item named Query write for each MySQL instance. Use this item as a mapping receiver when the mapping produces the complete SQL statement.
Do not change the UID of the automatically created Query write item.
Create a read item
- Open the MySQL instance.
- Open its Items section.
- Select Add item.
- Enter a descriptive item name.
- Select Read as the item direction.
- Enter a read query in Query default.
- Set the required polling interval and standard item settings.
- Select Save.
For example:
SELECT temperature, status
FROM machine_state
WHERE machine_id = 1
LIMIT 1A matching row can produce a value such as:
[{"temperature":21.5,"status":"running"}]The result is always returned as a JSON array. Each row becomes one JSON object and each selected column becomes a property.
Use a WHERE clause and LIMIT where appropriate. Returning an entire large table can consume significant memory and increase database and network load.
Statements blocked on read items
Read items are intended for queries that retrieve data. The Connector rejects the following modifying statements when it detects them in a read query:
UPDATEDELETEINSERT INTODROPTRUNCATE
Do not rely on this check as a database security control. Restrict the database account itself to the required permissions.
Execute a write query
A Write item does not execute the text stored in Query default. It executes the incoming item value as the SQL statement.
- Open or create the mapping that will send data to MySQL.
- Select the MySQL instance's Query write item as the receiver.
- Configure the mapping output so it produces a complete SQL statement.
- Save and enable the mapping.
- Trigger the mapping with a controlled test value.
- Confirm that the expected record was inserted or updated.
An incoming value can contain a statement such as:
INSERT INTO measurements (source, value)
VALUES ('line_1_temperature', 21.5)The Connector sends this text directly to MySQL. It does not automatically add quotes, escape text values, or convert the statement into a parameterized query.
Validate and escape dynamic text before it becomes part of an SQL statement. Prefer fixed statements, controlled mapping templates, stored procedures, and a least-privilege database account.
Understand returned data types
The Connector keeps compatible MySQL types when building the JSON result.
| MySQL value | Returned JSON value |
|---|---|
NULL |
null |
BOOLEAN or TINYINT(1) containing 0 or 1
|
JSON Boolean |
| Integer within the JSON safe-integer range | JSON number |
Integer outside -9007199254740991 to 9007199254740991
|
String to preserve the exact value |
FLOAT or DOUBLE
|
JSON number when the value is finite |
DECIMAL |
JSON number when precision can be preserved. High-precision values remain strings. |
Native MySQL JSON
|
Nested JSON object, array, scalar, or null
|
BLOB or another binary value |
Base64-encoded string |
| Text, date, or time | String |
Verify the configuration
- Create a Read item with a small query that returns one known row.
- Confirm that the item receives a JSON array containing the expected column names and values.
- Check that numbers, Boolean values, null values, and JSON columns have the expected JSON types.
- If writing is required, send a controlled statement to the Query write item.
- Verify the result using a separate database client or a Read item.
- Confirm that the database account cannot access tables or operations outside its intended scope.
Troubleshoot the MySQL Connector
The Connector returns the error text supplied by the MySQL client library and server. The exact numeric code and wording can differ between MySQL versions.
| Problem or message | Likely cause | Action |
|---|---|---|
| Failed to open database or Can't connect to MySQL server | The address or port is wrong, the server is stopped, remote connections are disabled, or a firewall blocks the connection. | Confirm the address and port. Check the MySQL service, bind address, firewall, routing, and DNS. Test basic reachability from SIA Connect. |
| Access denied for user | The username or password is wrong, the account does not permit connections from the SIA Connect host, or the authentication method is unavailable. | Verify the credentials and the account's permitted host. Confirm that the account can connect remotely using the required authentication method. |
| Unknown database | The database name is misspelled or the account cannot see it. | Enter the exact database name and confirm that the account has access. |
| MySQL SSL enabled but SSL_CA is missing: server certificate cannot be verified. | TLS is enabled without a selected CA certificate. | Upload the correct CA certificate, assign it the CA certificate category, and select it under SSL CA. |
| The TLS connection or certificate authentication fails | The CA is wrong, the client certificate and key do not match, the certificate is expired, the hostname is not accepted, or the selected cipher is unsupported. | Check the certificate chain, validity period, client certificate and key pair, database account requirements, server hostname, and cipher setting. Use Default (auto) unless a specific cipher is required. |
| Server has gone away, Lost connection, Connection reset, or Broken pipe | The server restarted, closed an idle connection, reached a timeout, or the network connection was interrupted. | Check the MySQL server and network. The Connector marks the cached connection for reconnection. If the error continues, review server timeout settings and the query size or duration. |
| You have an error in your SQL syntax | The SQL statement contains invalid MySQL syntax, missing quotes, or an incorrectly escaped value. | Run the exact statement in a MySQL client. Correct the syntax and confirm that the mapping produces valid SQL for every possible input. |
| Table doesn't exist | The table name, database, or letter case is wrong. | Confirm the selected database and use the exact table name. Qualify the table with its database name when needed. |
| Unknown column | The selected column is misspelled, missing, or interpreted as an identifier instead of a quoted text value. | Check the table schema and quote text values correctly. Use backticks only where an identifier requires them. |
| SELECT command denied, INSERT command denied, or another permission error | The database account lacks permission for the requested table or operation. | Grant only the required permission to the dedicated account. Confirm that the account is allowed to use the selected database. |
| Duplicate entry | An insert or update conflicts with a primary key or unique index. | Check the key value and decide whether the mapping should skip, update, or replace an existing row. |
| Column cannot be null | The statement supplies NULL or omits a required column. |
Provide a valid value or change the database schema only if null values are valid for the application. |
| Data too long for column or Out of range value | The value does not fit the column's length or numeric range. | Validate or transform the mapped value before building the statement. Confirm that the database column type matches the source data. |
| Empty query. Query: | The statement produced neither result columns nor affected rows. | Check that the query is complete and targets the intended database object. Run it in a MySQL client to confirm its behavior. |
| A read query cannot contain an UPDATE statement. or a similar warning for DELETE, INSERT, DROP, or TRUNCATE | A modifying statement was entered on a Read item. | Use a SELECT statement on the Read item. Send modifying SQL to the Query write item through a mapping. |
| A Read item has no new value | The query field is empty, the item is disabled, the polling interval has not elapsed, the query was rejected, or no usable result was returned. | Check Query default, item state, polling settings, item errors, and the system logs. Test the query directly against the same database account. |
| A write mapping runs but the database is unchanged | The incoming value is not a complete SQL statement, the target item is wrong, the statement affects no rows, or MySQL rejected it. | Confirm that the receiver is the correct Write item. Inspect the final generated SQL and the mapping error, then run the statement in a database client. |
| The returned JSON value has an unexpected type | The MySQL column type or value requires precision-preserving or binary conversion. | Review the source column type. Large integers and high-precision decimals can be strings, while binary values are Base64 encoded. |
If the problem continues, review the instance, item, and mapping errors together with the system logs. Query errors are assigned to the affected item or mapping. Connection-loss errors are also assigned to the instance and cause the Connector to reconnect on a later operation.