Elastic MySQL connector referenceedit

The Elastic MySQL connector is a connector for MySQL data sources.

Availability and prerequisitesedit

This connector is available as a native connector in Elastic versions 8.5.0 and later. To use this connector natively in Elastic Cloud, satisfy all native connector requirements.

This connector is also available as a connector client from the Python connectors framework. To use this connector as a connector client, satisfy all connector client requirements.

This connector has no additional prerequisites beyond the shared requirements, linked above.


To use this connector as a native connector, use the Connector workflow. See Native connectors.

To use this connector as a connector client, see Connector clients.

For additional operations, see Using connectors.

Known issuesedit

This connector has the following known issues:

  • Upgrading from a tech preview connector (8.7 or earlier) to 8.8 will cause the MySQL connector configuration to be invalid.

    MySQL connectors prior to 8.8 can be missing some configuration fields that are required for the connector to run. If you would like to continue using your MySQL connector after upgrading from 8.7 or earlier, run the script below to fix your connector’s configuration. This will populate the configuration with the missing fields. The auxilliary information needed for the configuration will then be automatically added by by the connector client.

    POST /.elastic-connectors/_update/<connector_id>
      "doc" : {
        "configuration": {
          "tables": {
            "type": "list",
            "value": "*"
          "ssl_enabled": {
            "type": "bool",
            "value": false
          "ssl_ca": {
            "type": "str",
            "value": ""
          "fetch_size": {
            "type": "int",
            "value": 50
          "retry_count": {
            "type": "int",
            "value": 3
  • Upgrading to 8.8 does not migrate MySQL sync rules.

    After upgrading, you must re-create your sync rules.

See Known issues for any issues affecting all connectors.


See Troubleshooting.


See Security.


This connector is compatible with MySQL 5.6 and later.

The connector is also compatible with MariaDB databases compatible with the above.

The data source and your Elastic deployment must be able to communicate with each other over a network.


Each time you create an index to be managed by this connector, you will create a new connector configuration. You will need some or all of the following information about the data source.


The IP address or domain name of the MySQL host, excluding port. Examples:

  • localhost

The port of the MySQL host. Examples:

  • 3306
  • 3307

The MySQL username the connector will use.

The user must have access to the configured database. You may want to create a dedicated, read-only user for each connector.

The MySQL password the connector will use.

The MySQL database to sync. The database must be accessible using the configured username and password.


  • products
  • orders

The tables in the configured database to sync. One or more table names, separated by commas. The tables must be accessible using the configured username and password.


  • furniture, food, toys
  • laptops
Enable SSL
Whether SSL verification will be enabled. Default value is True.
SSL Certificate

Content of SSL certificate. If SSL is disabled, the SSL certificate value will be ignored.

Expand to see an example certificate

Documents and syncsedit

The following describes the default syncing behavior for this connector. Use sync rules and ingest pipelines to customize syncing for specific indices.

All records in the MySQL database included in your connector configuration are extracted and transformed into documents in your Elasticsearch index.

  • For each row in your MySQL database table, the connector creates one Elasticsearch document.
  • For each column, the connector transforms the column into an Elasticsearch field.
  • Elasticsearch dynamically maps MySQL data types to Elasticsearch data types.
  • Tables with no primary key defined are skipped.
  • Field values that represent other records are replaced with the primary key for that record (composite primary keys are joined with _).

The Elasticsearch mapping is created when the first document is created.

Each sync is a "full" sync.

For each MySQL row discovered:

  • If it does not exist, the document is created in Elasticsearch.
  • If it already exists in Elasticsearch, the Elasticsearch document is replaced and the version is incremented.
  • If an existing Elasticsearch document no longer exists in the MongoDB collection, it is deleted from Elasticsearch.

Deployment using Dockeredit

You can deploy the MySQL connector as a self-managed connector client using Docker. Follow these instructions.

Step 1: Download sample configuration file

Download the sample configuration file. You can either download it manually or run the following command:

curl https://raw.githubusercontent.com/elastic/connectors-python/main/config.yml --output ~/connectors-python-config/config.yml

Remember to update the --output argument value if your directory name is different, or you want to use a different config file name.

Step 2: Update the configuration file for your self-managed connector

Update the configuration file with the following settings to match your environment:

  • elasticsearch.host
  • elasticsearch.api_key
  • connectors

If you’re running the connector service against a Dockerized version of Elasticsearch and Kibana, your config file will look like this:

# When connecting to your cloud deployment you should edit the host value
elasticsearch.host: http://host.docker.internal:9200
elasticsearch.api_key: <ELASTICSEARCH_API_KEY>

    connector_id: <CONNECTOR_ID_FROM_KIBANA>
    service_type: mysql

Using the elasticsearch.api_key is the recommended authentication method. However, you can also use elasticsearch.username and elasticsearch.password to authenticate with your Elasticsearch instance.

Note: You can change other default configurations by simply uncommenting specific settings in the configuration file and modifying their values.

Step 3: Run the Docker image

Run the Docker image with the Connector Service using the following command:

docker run \
-v ~/connectors-python-config:/config \
--network "elastic" \
--tty \
--rm \
docker.elastic.co/enterprise-search/elastic-connectors: \
/app/bin/elastic-ingest \
-c /config/config.yml

Refer to this guide in the Python framework repository for more details.

Sync rulesedit

The following sections describe Sync rules for this connector.

Basic sync rules are identical for all connectors and are available by default.

Advanced rules for MySQL can be used to pass arbitrary SQL statements to a MySQL instance.

You need to specify the tables used in your custom query in the "tables" field.

For example:

        "tables": ["table1", "table2"],
        "query": "SELECT ... FROM ..."

When using advanced rules, a query can bypass the configuration fields "database" and "tables". This will happen if the query specifies a database and/or table that doesn’t appear in the configuration. This can also happen if the configuration specifies * to fetch all tables while the advanced sync rule requests for only a subset of tables.

Content extractionedit

See Content extraction.

Framework and sourceedit

This connector is included in the Python connectors framework.

View the source code for this connector (branch 8.10, compatible with Elastic 8.10).