All Products
Search
Document Center

E-MapReduce:MySQL connector

Last Updated:Mar 26, 2026

The MySQL connector lets Trino query and write data in an external MySQL database. Use it to run federated queries that join MySQL tables with other data sources in your cluster, such as Hive or Iceberg tables, or to join data across two MySQL instances.

Prerequisites

Before you begin, ensure that you have:

Limitations

  • Only Hadoop or Trino clusters on E-MapReduce (EMR) V3.38.0 and later support the MySQL connector.

  • Supported MySQL versions: 5.7, 8.0, or later (ApsaraDB RDS for MySQL only).

  • The coordinator node and all worker nodes must be able to reach MySQL. The default port is 3306.

  • The following SQL statements are not supported: DELETE, GRANT, REVOKE, SHOW GRANTS, SHOW ROLES, SHOW ROLE GRANTS.

Configure the MySQL connector

For general connector configuration steps, see Configure a connector.

Minimum required configuration

Each MySQL catalog is defined by a .properties file. The minimum configuration requires three properties:

connection-url=jdbc:mysql://rm-2ze5ipacsu8265q****.mysql.rds.aliyuncs.com:3306
connection-user=<your-username>
connection-password=<your-password>

To find your connection-url, see View and manage instance endpoints and ports.

In the EMR console, these properties map to configuration items on the mysql.properties tab of the Trino service's Configure tab.

Configuration itemDescription
connection-urlThe JDBC URL of your ApsaraDB RDS for MySQL instance.
connection-userThe username for database access. The account must have read (and write, if needed) permissions on the target tables.
connection-passwordThe password for the account specified by connection-user.

Connect to multiple MySQL instances

To connect Trino to more than one MySQL instance, create a separate .properties file for each instance in the etc/catalog directory. Each file name becomes the catalog name in Trino — for example, sales.properties creates a catalog named sales.

File names must be unique and end with .properties.

To add a second MySQL catalog using the EMR console:

  1. On the Configure tab of the Trino service, click the mysql.properties tab. Set connection-url, connection-user, and connection-password for your first MySQL instance. To add properties not listed by default, click Add Configuration Item at the top of the tab. For details, see the Add configuration items section of "Manage configuration items".

  2. Click the connector[x].properties tab (where x is an integer starting from 1) to configure additional MySQL catalogs. Repeat for each additional instance.

  3. Save the configuration:

    1. At the bottom of the Configure tab, click Save.

    2. In the dialog box, enter a reason in Execution Reason and click Save.

  4. Restart the Trino service:

    1. In the upper-right corner, choose More > Restart.

    2. Enter a reason in Execution Reason and click OK.

    3. In the Confirm dialog, click OK.

Data type mappings

DECIMAL type with precision greater than 38

MySQL's DECIMAL type supports precision up to 65, but Trino's DECIMAL type supports a maximum precision of 38. To map a MySQL DECIMAL(p, s) where p > 38, set the decimal_mapping configuration property (or the corresponding session property) to allow_overflow. The mapped Trino type uses a fixed precision of 38; the scale is controlled by decimal-default-scale and the rounding behavior by decimal-rounding-mode.

By default, any value that requires rounding or truncation during mapping causes a runtime failure. Set decimal-rounding-mode to one of the following values to change this behavior:

ValueBehavior
UNNECESSARYFail if rounding is required (default)
UPRound away from zero
DOWNRound toward zero
CEILINGRound toward positive infinity
FLOORRound toward negative infinity
HALF_UPRound toward nearest neighbor; ties round up
HALF_DOWNRound toward nearest neighbor; ties round down
HALF_EVENRound toward nearest neighbor; ties round to even

General configuration properties

Use the following properties to control how unsupported data types are handled and how metadata is cached.

PropertyDescriptionDefault
unsupported-type-handlingHow to handle columns with unsupported data types. IGNORE makes those columns inaccessible; CONVERT_TO_VARCHAR converts them to unbounded VARCHAR.IGNORE
jdbc-types-mapped-to-varcharForces conversion of comma-separated JDBC types to unbounded VARCHAR.
case-insensitive-name-matchingWhen set to true, database and table names are matched case-insensitively.false
case-insensitive-name-matching.cache-ttlHow long to cache case-insensitive name mappings.1 minute
metadata.cache-ttlHow long to cache table and column statistics. Set to 0 to disable caching.0 (disabled)
metadata.cache-missingWhen set to true, the absence of metadata (e.g., a missing table) is also cached.false

Query MySQL data

The MySQL connector maps each MySQL database to a Trino schema. All queries use the three-level naming format catalog.schema.table, where catalog is the name of your .properties file (for example, mysql).

Step 1: Log on to the cluster over SSH. See Log on to a cluster.

Step 2: Connect to the Trino CLI.

For a DataLake cluster:

trino --server master-1-1:9090 --catalog iceberg --schema default

For a Hadoop or Trino cluster:

trino --server emr-header-1:9090 --catalog iceberg --schema default

Step 3: List all MySQL databases available in the catalog.

SHOW SCHEMAS FROM mysql;

Step 4: List tables in a specific database. In this example, web is the name of an ApsaraDB RDS for MySQL database.

SHOW TABLES FROM mysql.web;

Step 5: Inspect the columns in a table.

DESCRIBE mysql.web.clicks;

Alternatively:

SHOW COLUMNS FROM mysql.web.clicks;

Step 6: Query the table.

SELECT * FROM mysql.web.clicks;

Pushdown

The MySQL connector supports pushdown for the following operators and functions. Pushdown moves computation to the MySQL side, reducing the data transferred to Trino.

Important

Pushdown is applied where it improves performance. When pushing down an operation risks incorrect results, the connector prioritizes correctness and executes the operation in Trino instead.

Operators:

  • Join

  • Limit

  • Top-N

Functions:

  • avg()

  • count()

  • max()

  • min()

  • sum()

  • stddev()

  • stddev_pop()

  • stddev_samp()

  • variance()

  • var_pop()

  • var_samp()

For more details on how pushdown works in Trino, see Pushdown in the Trino documentation.