Following are the configuration values that you might need to adjust for your MySQL databaseconnection.url connection.url=jdbc:mysql://127.0.0.1:3306/<DatabaseName>?user=<username>&password=<password>username and password are the user credentials with which you login to MySQL Database.incrementing.column.name

The name of the strictly incrementing column in the tables of your database to use to detect new rows. Any empty value indicates the column should be autodetected by looking for an auto-incrementing column. This column may not be nullable. If you don’t have a column with these properties, you may update one of the column with following SQL Commands.

topic.prefix Prefix to prepend to table names to generate the name of the Kafka topic to publish data to, or in the case of a custom query, the full name of the topic to publish to. Example : If yourtopic.prefix=test-mysql-jdbc- and if you have a table namedstudents in your Database, the topic name to which Connector publishes the messages would betest-mysql-jdbc-students .

Start Zookeeper, Kafka and Schema Registry

To start Zookeeper, Kafka and Schema Registry, run the following confluent command

Start a Console Consumer.

To verify the messages posted to the topic, start a consumer that subscribes to topic named test-mysql-jdbc-students. [students is the table name andtest-mysql-jdbc- is topic.prefix] Run the following command to start a consumer

Using the ConsoleConsumer with old consumer isdeprecated andwill be removed inafuture major release.Consider using the newconsumer by passing[bootstrap-server]instead of[zookeeper].

{"name":{"string":"John"},"rollno":1,"marks":{"int":84}}

{"name":{"string":"Arjun"},"rollno":2,"marks":{"int":84}}

{"name":{"string":"Prasanth"},"rollno":3,"marks":{"int":77}}

{"name":{"string":"Adarsh"},"rollno":4,"marks":{"int":78}}

{"name":{"string":"Raja"},"rollno":5,"marks":{"int":94}}

{"name":{"string":"Sai"},"rollno":6,"marks":{"int":84}}

{"name":{"string":"Ross"},"rollno":7,"marks":{"int":54}}

{"name":{"string":"Monica Gellar"},"rollno":8,"marks":{"int":86}}

{"name":{"string":"Lee"},"rollno":9,"marks":{"int":98}}

{"name":{"string":"Bruce Wane"},"rollno":10,"marks":{"int":92}}

{"name":{"string":"Jack"},"rollno":11,"marks":{"int":82}}

{"name":{"string":"Priya"},"rollno":12,"marks":{"int":88}}

{"name":{"string":"Amy"},"rollno":13,"marks":{"int":84}}

{"name":{"string":"Sastri"},"rollno":14,"marks":{"int":88}}

Conclusion :

In this Apache Kafka Tutorial – Kafka Connector to MySQL Source, we have learnt to setup a Connector to import data to Kafka from MySQL Database Source using Confluent JDBC Connector and MySQL Connect Driver.