flink-cdc icon indicating copy to clipboard operation
flink-cdc copied to clipboard

无法指定链接参数 AllowPublicKeyRetrieval=True

Open springMoon opened this issue 3 years ago • 7 comments

在使用 mysql 8.0 的时候报下面的,需要指定链接参数 AllowPublicKeyRetrieval=True,但是没有找到配置的地方 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:836) at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) at io.debezium.jdbc.JdbcConnection.lambda$patternBasedFactory$1(JdbcConnection.java:230) at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:871) at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:866) at io.debezium.jdbc.JdbcConnection.connect(JdbcConnection.java:412) at io.debezium.connector.mysql.MySqlJdbcContext.querySystemVariables(MySqlJdbcContext.java:328) ... 11 more

springMoon avatar Apr 26 '21 06:04 springMoon

我也遇到了同样的问题

xiaohui1227 avatar May 14 '21 04:05 xiaohui1227

我也遇到了同样的问题

如果只是自己开发,可以先用cdc的账号先登录一下

springMoon avatar May 19 '21 11:05 springMoon

我也遇到了同样的问题

如果只是自己开发,可以先用cdc的账号先登录一下

没懂,是这样?还是不行呢。

--FlinkSQL CREATE TABLE products ( id INT, name STRING, description STRING ) WITH ( 'connector' = 'mysql-cdc', 'hostname' = 'localhost', 'port' = '3306', 'username' = 'mysqluser', 'password' = 'mysqlpw', 'database-name' = 'mydb', 'table-name' = 'products' );

afghl avatar Jul 29 '21 14:07 afghl

有人解决了这个问题吗

lpong avatar Nov 01 '21 11:11 lpong

指定参数 'debezium.database.allowPublicKeyRetrieval' = 'true' Debezium & MySQL v8 : Public Key Retrieval Is Not Allowed

nukiyoam avatar Nov 11 '21 09:11 nukiyoam

我的密码策略时mysql_native_password,我的原因找到了,是因为用户名和密码错了(没有这个用户),提示也是 Public Key Retrieval Is Not Allowed

lpong avatar Nov 11 '21 10:11 lpong

You can also modify the JDBC parameters by adding useSSL = False and allowPublicKeyRetrieval= True in case don't plan to change any configuration on the server:

Configure for DataStream as below:

    Properties jdbcProperties = new Properties
    jdbcProperties.setProperty("useSSL", "false")
    jdbcProperties.setProperty("allowPublicKeyRetrieval", "true")
    MySqlSource.<String>builder()
      ...
      .jdbcProperties(jdbcProperties)
      .build();

Configure for Flink SQL as below:

Flink SQL> CREATE TABLE table (
     ...
     ) WITH (
     'connector' = 'mysql-cdc',
     ...
     'jdbc.properties.useSSL' = 'false',
     'jdbc.properties.allowPublicKeyRetrieval' = 'true');

saLeox avatar Aug 29 '22 11:08 saLeox

Properties jdbcProperties = new Properties jdbcProperties.setProperty("useSSL", "false") jdbcProperties.setProperty("allowPublicKeyRetrieval", "true") 添加这两个参数之后不报错了,但是我监听两个mysql表,只能监听到一张表的binlog,而且只能是第一全量,之后无法动态获取到这张表的binlog日志。另外一张表从flink日志看到监听sql,不知道为什么有过滤条件。

liushuaihang avatar Nov 18 '22 05:11 liushuaihang

我的表环境配置 'debezium.database.allowPublicKeyRetrieval' = 'true',\n" 就可以了 奇怪的用root 用户就没有此问题

cyrusmaster avatar Apr 26 '23 10:04 cyrusmaster

Closing this issue because it was created before version 2.3.0 (2022-11-10). Please try the latest version of Flink CDC to see if the issue has been resolved. If the issue is still valid, kindly report it on Apache Jira under project Flink with component tag Flink CDC. Thank you!

PatrickRen avatar Feb 28 '24 15:02 PatrickRen