title: Kafka connect with mysql for CDC: error Aborting snapshot due to error when last running 'UNLOCK TABLES'
body: <p>I was trying to capture mysql change into kafka console consumer following this <a href="http://Aborting%20snapshot%20due%20to%20error%20when%20last%20running%20&#39;UNLOCK%20TABLES&#39;:%20com/mysql/jdbc/CharsetMapping%20(io.debezium.connector.mysql.SnapshotReader:162)." rel="nofollow noreferrer">tutorial</a></p>
  
  <p>In mysql conf file <code>my.cnf</code>, I have added <code>server-id</code> as <code>0</code> [found by this command:  <code>mysqld --verbose --help</code>].
  So, when creating connector by this:</p>
  
  <pre><code>curl -i -X POST -H "Accept:application/json" \
      -H  "Content-Type:application/json" http://localhost:8083/connectors/ \
      -d '{
        "name": "mysql-connector8",
        "config": {
              "connector.class": "io.debezium.connector.mysql.MySqlConnector",
              "database.hostname": "localhost",
              "database.port": "3306",
              "database.user": "debezium",
              "database.password": "dbz",
              "database.server.id": 1,
              "database.server.name": "tigerhrm",
              "database.history.kafka.bootstrap.servers": "localhost:9092",
              "database.history.kafka.topic": "dbhistory.demo3" ,
              "include.schema.changes": "true",
              "tasks.max":1
         }
      }'
  </code></pre>
  
  <p>when I set server.id=0 as set in my <code>my.cnf</code> file, it gives error, but when change to any random number, connector created but gives a subsequent error:</p>
  
  <blockquote>
    <p>[2020-02-06 11:58:25,190] INFO    USE <code>flyDB</code>
    (io.debezium.connector.mysql.SnapshotReader:803) [2020-02-06
    11:58:25,191] INFO    CREATE TABLE <code>oauth_access_token</code> (   <code>token_id</code>
    varchar(255) DEFAULT NULL,   <code>token</code> blob,   <code>authentication_id</code>
    varchar(255) NOT NULL,   <code>user_name</code> varchar(255) DEFAULT NULL,<br>
    <code>client_id</code> varchar(255) DEFAULT NULL,   <code>authentication</code> blob,<br>
    <code>refresh_token</code> varchar(255) DEFAULT NULL,   PRIMARY KEY
    (<code>authentication_id</code>) ) ENGINE=InnoDB DEFAULT CHARSET=latin1
    (io.debezium.connector.mysql.SnapshotReader:803) [2020-02-06
    11:58:25,192] INFO Step 7: committing transaction
    (io.debezium.connector.mysql.SnapshotReader:611) [2020-02-06
    11:58:25,193] INFO Step 8: releasing global read lock to enable MySQL
    writes (io.debezium.connector.mysql.SnapshotReader:625) [2020-02-06
    11:58:25,193] INFO Writes to MySQL tables prevented for a total of
    00:00:00.684 (io.debezium.connector.mysql.SnapshotReader:635)
    [2020-02-06 11:58:25,193] ERROR Failed due to error: Aborting snapshot
    due to error when last running 'UNLOCK TABLES':
    com/mysql/jdbc/CharsetMapping
    (io.debezium.connector.mysql.SnapshotReader:162)
    org.apache.kafka.connect.errors.ConnectException:
    com/mysql/jdbc/CharsetMapping     at
    io.debezium.connector.mysql.AbstractReader.wrap(AbstractReader.java:183)
      at
    io.debezium.connector.mysql.AbstractReader.failed(AbstractReader.java:161)
      at
    io.debezium.connector.mysql.SnapshotReader.execute(SnapshotReader.java:665)
      at java.lang.Thread.run(Thread.java:748) Caused by:
    java.lang.NoClassDefFoundError: com/mysql/jdbc/CharsetMapping     at
    io.debezium.connector.mysql.MySqlValueConverters.charsetFor(MySqlValueConverters.java:300)
      at
    io.debezium.connector.mysql.MySqlValueConverters.converter(MySqlValueConverters.java:270)
      at
    io.debezium.relational.TableSchemaBuilder.createValueConverterFor(TableSchemaBuilder.java:330)
      at
    io.debezium.relational.TableSchemaBuilder.convertersForColumns(TableSchemaBuilder.java:259)
      at
    io.debezium.relational.TableSchemaBuilder.createKeyGenerator(TableSchemaBuilder.java:148)
      at
    io.debezium.relational.TableSchemaBuilder.create(TableSchemaBuilder.java:127)
      at
    io.debezium.connector.mysql.MySqlSchema.lambda$applyDdl$3(MySqlSchema.java:365)
      at java.lang.Iterable.forEach(Iterable.java:75)     at
    io.debezium.connector.mysql.MySqlSchema.applyDdl(MySqlSchema.java:360)
      at
    io.debezium.connector.mysql.SnapshotReader.lambda$execute$9(SnapshotReader.java:422)
      at io.debezium.jdbc.JdbcConnection.query(JdbcConnection.java:389)   at
    io.debezium.jdbc.JdbcConnection.query(JdbcConnection.java:344)    at
    io.debezium.connector.mysql.SnapshotReader.execute(SnapshotReader.java:420)
      ... 1 more</p>
  </blockquote>
  
  <p>where <code>oauth_access_token</code> is a table in my db[there exists multiple db].
  Checking connectors' status I got this:</p>
  
  <pre><code>curl -s "http://localhost:8083/connectors" |  jq '.[]' | xargs -I {mysql-connector} curl -s "http://localhost:8083/connectors/mysql-connector/status" | jq -c -M '[.name,.connector.state,.tasks[].state] |
  join(":|:")' | column -s : -t | tr -d \" | sort
  mysql-connector  |  RUNNING  |  FAILED
  mysql-connector  |  RUNNING  |  FAILED
  mysql-connector  |  RUNNING  |  FAILED
  mysql-connector  |  RUNNING  |  FAILED
  mysql-connector  |  RUNNING  |  FAILED
  mysql-connector  |  RUNNING  |  FAILED
  mysql-connector  |  RUNNING  |  FAILED
  mysql-connector  |  RUNNING  |  FAILED
  </code></pre>
  
  <p>, Last column is their task status. and hence no database change is detected in topic where topic should be created named by the tables existed in db. How to solve this ?<br>
  Add: when I delete that table from db, the error occurs for another table and goes on !All services are running on my local ubuntu machine.
  .<br> Any kind of help is much appreciated!</p>