Skip to content

Connect to EMQX Tables via MySQL

EMQX Tables supports the MySQL server-client protocol, allowing users and applications to connect directly for querying and managing time-series data.

This interface is fully compatible with most standard MySQL clients and drivers. It is useful for integrating with BI tools, custom applications, or running SQL queries programmatically.

All connections are encrypted with TLS, ensuring secure data transmission.

Connection Parameters

To connect to EMQX Tables in MySQL protocol, use the information below. You can find the host, database name, and port on the EMQX Tables Deployment Overview page. Create or manage the username and password in User Management.

  • Host: {YOUR_EMQX_TABLES_PUBLIC_HOST}
  • Port: 4002
  • Database: {YOUR_EMQX_TABLES_DB_NAME}
  • Username: {YOUR_EMQX_TABLES_USERNAME}
  • Password: {YOUR_EMQX_TABLES_PASSWORD}

Connect via CLI

MySQL CLI

You can use the standard MySQL client to connect:

shell
mysql --ssl-mode=REQUIRED -u {USER} -p -h {HOST} -P 4002 -A {DB_NAME}

Version Compatibility

If you are using a MySQL client version 9.0 or later, connection attempts may fail (ERROR 2059) due to the removal of the mysql_native_password plugin.

We recommend using a MySQL 8.0 client. Alternatively, you can use the following Docker command (using the mysql:8.0 image) to test the connection:

bash
docker run -it --rm mysql:8.0 mysql --ssl-mode=REQUIRED -h {HOST} -P 4002 -u {USER} -p

MariaDB CLI

MariaDB’s CLI supports similar syntax, with a slightly different SSL flag:

shell
mysql --ssl -u {USER} -p -h {HOST} -P 4002 -A {DB_NAME}

Connect via Applications

JDBC Connection String

Use the following JDBC URL format when connecting from Java or BI tools:

text
jdbc:mysql://{HOST}:4002/{DB_NAME}?user={USER}&password=~~{PASSWORD}~~

Python or Other Clients

For Python or other languages using MySQL-compatible libraries, use this URL format:

text
mysql://{USER}:~~{PASSWORD}~~@{HOST}:4002/{DB_NAME}