问题遇到的现象和发生背景
使用flinkcdc连接mysqlblinlog日志
DebeziumSourceFunction<String> sourceFunction = MySQLSource.<String>builder()
.hostname("localhost")
.port(3306)
.username("hello")
.password("1234")
.databaseList("flinkCdc")
.tableList("home")
.deserializer(new StringDebeziumDeserializationSchema())
.serverId(1)
.serverTimeZone("UTC")
.build();
问题相关代码,请勿粘贴截图
运行结果及报错内容
Caused by: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
我的解答思路和尝试过的方法
Properties properties=new Properties();
properties.setProperty("allowPublicKeyRetrieval","true");
//创建flinkcdc监控Mysqlblinlog日志
DebeziumSourceFunction<String> sourceFunction = MySQLSource.<String>builder()
.hostname("localhost")
.port(3306)
.username("hello")
.password("1234")
.databaseList("flinkCdc")
.tableList("home")
.deserializer(new StringDebeziumDeserializationSchema())
.serverId(1)
.debeziumProperties(properties)
.serverTimeZone("UTC")
.build();
我想要达到的结果
能不报错,顺利运行。