Underlying cause: java.sql.SQLNonTransientConnectionException : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
本人是在初始化Hive的过程中遇到的错误。
这个错误 Public Key Retrieval is not allowed
表示 MySQL 在使用默认的 caching_sha2_password
插件进行身份验证时,客户端没有正确地检索到公钥来完成密码验证。这通常发生在 MySQL 8.0 或更高版本中,它默认使用 caching_sha2_password
插件,而某些 JDBC 连接未启用 public key retrieval
选项来允许检索公钥。
你可以通过修改 JDBC 连接 URL 来允许公钥检索。只需在 Hive 配置中的 JDBC URL 后添加 allowPublicKeyRetrieval=true
,并确保 useSSL=false
。
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>
jdbc:mysql://XXX.XXX.XXX.XXX:3306/hive?createDatabaseIfNotExist=true&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
</value>
</property>