CLOUD
Note
If you are installing the connector locally for Confluent Platform, see JDBC Connector (Source and Sink) for Confluent Platform.
The Kafka Connect MySQL Source connector for Confluent Cloud can obtain a snapshot of the existing data in a MySQL database and then monitor and record all subsequent row-level changes to that data. The connector supports Avro, JSON Schema, Protobuf, or JSON (schemaless) output data formats. All of the events for each table are recorded in a separate Apache Kafka® topic. The events can then be easily consumed by applications and services. Note that deleted records are not captured.
Important
If you are still on Confluent Cloud Enterprise, please contact your Confluent Account Executive for more information about using this connector.
The MySQL source connector provides the following features:
Topics created automatically: The connector automatically creates Kafka topics using the naming convention: <database.server.name>.<schemaName>.<tableName>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3.
<database.server.name>.<schemaName>.<tableName>
topic.creation.default.partitions=1
topic.creation.default.replication.factor=3
Insert modes:
timestamp mode is enabled when only a timestamp column is specified when you enter database details.
timestamp+incrementing mode is enabled when both a timestamp column and incrementing column are specified when you enter database details.
A timestamp column must not be nullable.
Database authentication: Uses password authentication.
Data formats: The connector supports Avro, JSON Schema, Protobuf, or JSON (schemaless) output data. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).
Select configuration properties:
db.timezone
poll.interval.ms
batch.max.rows
timestamp.delay.interval.ms
topic.prefix
schema.pattern
Configuration properties that are not shown in the Confluent Cloud UI use the default values. See JDBC Connector Source Connector Configuration Properties for default values and property definitions.
You can manage your full-service connector using the Confluent Cloud API. For details, see the Confluent Cloud API documentation.
Refer to Confluent Cloud connector limitations for additional information.
Use this quick start to get up and running with the Confluent Cloud MySQL source connector. The quick start shows how to select the connector and configure it to capture a snapshot of the existing data in a MySQL database. It then monitors and records all subsequent row-level changes.
Authorized access to a Confluent Cloud cluster on Amazon Web Services (AWS), Microsoft Azure (Azure), or Google Cloud Platform (GCP).
The Confluent Cloud CLI installed and configured for the cluster. See Install and Configure the Confluent Cloud CLI.
The connector automatically creates Kafka topics using the naming convention: <prefix>.<table-name>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3. If you want to create topics with specific settings, please create the topics before running this connector.
<prefix>.<table-name>
Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).
Public access may be required for your database. See Internet Access to Resources for details. The example below shows the AWS Management Console when setting up a MySQL database.
Public access enabled
Public inbound traffic access (0.0.0.0/0) may be required for the VPC where the database is located, unless the environment is configured for VPC peering. See Internet Access to Resources for details. The example below shows the AWS Management Console when setting up security group rules for the VPC. See your specific cloud platform documentation for details about how to configure security rules for a VPC.
0.0.0.0/0
Open inbound traffic
A specific database timezone must be set before creating a MySQL source connector for Azure. See Working with the time zone parameter for more information.
See the Quick Start for Apache Kafka using Confluent Cloud for installation instructions.
Click Connectors. If you already have connectors in your cluster, click Add connector.
Click the MySQL Source connector icon.
Complete the following and click Continue.
Enter a connector name.
Enter your Kafka Cluster credentials. The credentials are either the API key and secret or the service account API key and secret.
Enter a topic prefix. The connector automatically creates Kafka topics using the naming convention: <prefix>.<table-name>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3. If you want to create topics with specific settings, please create the topics before running this connector.
Add the connection details for the database.
Do not include jdbc:xxxx:// in the Connection host field. The example below shows a sample host address.
jdbc:xxxx://
Add the Database details for your database. Review the following notes for more information about field selections.
Enter a Timestamp column name to enable timesamp mode. This mode uses a timestamp (or timestamp-like) column to detect new and modified rows. This assumes the column is updated with each write, and that values are monotonically incrementing, but not necessarily unique.
Enter both a Timestamp column name and an Incrementing column name to enable timestamp+incrementing mode. This mode uses two columns, a timestamp column that detects new and modified rows, and a strictly incrementing column which provides a globally unique ID for updates so each row can be assigned a unique stream offset.
By default, the connector only detects tables with type TABLE from the source database. Use VIEW for virtual tables created from joining one or more tables. Use ALIAS for tables with a shortened or temporary name.
Add the Connection details for your connection to the database.
Select an Output message format (data coming from the connector): AVRO, JSON_SR (JSON Schema), PROTOBUF, or JSON (schemaless). A valid schema must be available in Schema Registry to use a schema-based message format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).
Enter the number of tasks in use by the connector. For additional information, see connector limitations.
Verify the connection details and click Launch.
The status for the connector should go from Provisioning to Running. It may take a few minutes.
After the connector is running, verify that messages are populating your Kafka topic.
For more information about this connector, see the JDBC Source Connector for Confluent Platform. Note that not all Confluent Platform connector features are provided in the Confluent Cloud connector.
See also
For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent Cloud CLI to manage your resources in Confluent Cloud.
Complete the following steps to set up and run the connector using the Confluent Cloud CLI.
Make sure you have all your prerequisites completed.
Enter the following command to list available connectors:
ccloud connector-catalog list
Enter the following command to show the required connector properties:
ccloud connector-catalog describe <connector-catalog-name>
For example:
ccloud connector-catalog describe MySqlSource
Example output:
Following are the required configs: connector.class name kafka.api.key kafka.api.secret topic.prefix connection.host connection.port connection.user connection.password db.name table.whitelist timestamp.column.name output.data.format tasks.max
Create a JSON file that contains the connector configuration properties. The following example shows the required connector properties.
{ "name" : "confluent-mysql-source", "connector.class": "MySqlSource", "kafka.api.key": "<my-kafka-api-key>", "kafka.api.secret" : "<my-kafka-api-secret>", "topic.prefix" : "mysql_", "connection.host" : "<my-database-endpoint>", "connection.port" : "3306", "connection.user" : "<database-username>", "connection.password": "<database-password>", "db.name": "mysql-test", "table.whitelist": "passengers", "timestamp.column.name": "created_at", "output.data.format": "JSON", "db.timezone": "UCT", "tasks.max" : "1" }
Note the following property definitions:
"name": Sets a name for your new connector.
"name"
"connector.class": Identifies the connector plugin name.
"connector.class"
"topic.prefix": Enter a topic prefix. The connector automatically creates Kafka topics using the naming convention: <prefix>.<table-name>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3. If you want to create topics with specific settings, please create the topics before running this connector.
"topic.prefix"
"output.data.format": Sets the output message format (data coming from the connector). Valid entries are AVRO, JSON_SR, PROTOBUF, or JSON. You must have Confluent Cloud Schema Registry configured if using a schema-based message format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).
"output.data.format"
"db.timezone": Identifies the database timezone. This can be any valid database timezone. The default is UTC. For more information, see this list of database timezones.
"db.timezone"
Configuration properties that are not listed use the default values. For default values and property definitions, see JDBC Connector Source Connector Configuration Properties.
Enter the following command to load the configuration and start the connector:
ccloud connector create --config <file-name>.json
ccloud connector create --config mysql-source.json
Created connector confluent-mysql-source lcc-ix4dl
Enter the following command to check the connector status:
ccloud connector list
ID | Name | Status | Type +-----------+------------------------+---------+-------+ lcc-ix4dl | confluent-mysql-source | RUNNING | source
For additional information about this connector see JDBC Source Connector for Confluent Platform. Note that not all Confluent Platform connector features are provided in the Confluent Cloud connector.