Skip to main content

MariaDB Overview

The MARIADB route stores MQTT messages in MariaDB databases. MariaDB is a MySQL-compatible database with enhanced features and performance optimizations.
MariaDB offers drop-in MySQL compatibility with additional features like improved replication and storage engines. Use the same configuration as MySQL with the MARIADB route type.

Basic Syntax


Connection Configuration

SQL_CONFIG Parameters

SERVER
string
required
MariaDB server hostname or IP address.
DATABASE
string
required
Target database name.
USERNAME
string
required
Database username.
PASSWORD
string
required
Database password.
PORT
integer
MariaDB port. Default: 3306.
USE_SSL
boolean
Enable SSL connection. Default: false.
Never hardcode credentials in production. Use environment variables and encrypted secrets to keep sensitive values out of your route definitions:
See Environment Variables & Secrets for setup and usage.

Writing Data

Store sensor data in MariaDB:
Alternative: STORE IN with Models — Instead of writing EVENT queries, you can bind a model directly to this route. Every PUBLISH MODEL call automatically inserts a row — no query needed:
See Data Storage Overview for the full STORE IN workflow.

Reading Data

EVENTs also support SELECT queries to read data back from the database. Publish a message to the event’s SOURCE_TOPIC, and the query result is published to DESTINATION_TOPIC:
To trigger this query, publish the sensor ID to the source topic:
The query result is published to db/result/latest, where your actions or external clients can consume it.

Timed Polling

EVENTs can also run SELECT queries on a fixed schedule using WITH EVERY:

Troubleshooting

  • Verify SERVER and PORT are correct
  • Check MariaDB is running and accepting connections
  • Verify firewall allows connections on port 3306
  • Verify USERNAME and PASSWORD are correct
  • Check user has permissions on the DATABASE
  • Verify user can connect from your host

Next Steps

Data Storage Routes Overview

Compare all storage options.

SQL Server Route

Configure Microsoft SQL Server storage.
Last modified on May 22, 2026