MySQLNonTransientConnectionException Public Key Retrieval is not allowed
时间: 2023-11-16 13:00:11 浏览: 21
MySQLNonTransientConnectionException Public Key Retrieval is not allowed是一个MySQL数据库连接异常,意味着在使用sha256_password认证时,客户端无法从服务器请求公钥。这个问题可以通过将allowPublicKeyRetrieval设置为true来解决。如果你使用的是DBeaver数据库客户端连接MySQL,可以通过右键点击数据库连接,选择编辑连接,然后点击驱动属性,将allowPublicKeyRetrieval设置为true来解决这个问题。
相关问题
MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
MySQLNonTransientConnectionException: Public Key Retrieval is not allowed 是一个Java异常错误信息,表示在MySQL数据库连接时发生了问题。具体而言,可能是由于连接字符串URL中缺少 "allowPublicKeyRetrieval=true" 参数导致的。为了解决这个异常,可以尝试以下几种方法:
1. 修改MySQL数据库连接字符串URL,在末尾添加 "?allowPublicKeyRetrieval=true" 参数。例如:
```java
String url = "jdbc:mysql://localhost:3306/mydatabase?allowPublicKeyRetrieval=true&useSSL=false";
```
2. 如果使用的是Java 8及以上版本,您可以将SSL模式设置为 "false",通过在JDBC驱动程序中添加额外的属性来关闭SSL。例如:
```java
String url = "jdbc:mysql://localhost:3306/mydatabase?sslMode=DISABLED";
```
在这种情况下,您可能不需要 "allowPublicKeyRetrieval=true" 参数选项。
3. 更新MySQL Connector/J驱动程序到最新版本。如果您正在使用旧版本的MySQL Connector/J驱动程序,建议您将驱动程序更新到最新版本,并重新尝试连接,因为较新版本的驱动程序可能修复了一些与公钥检索相关的问题。
希望以上方法能够解决您遇到的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [报错MySQLNonTransientConnectionException: Public Key Retrieval is not allowed 解决方法](https://blog.csdn.net/qq_53332052/article/details/131596103)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [解决问题:java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowe](https://blog.csdn.net/qq_51447496/article/details/131147302)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
Public Key Retrieval is not allowed Public Key Retrieval is not allowed
回答: "Public Key Retrieval is not allowed"错误通常是由于禁用了SSL/TLS协议传输导致的。在禁用SSL/TLS协议传输后,客户端需要使用服务器的公钥进行传输,但默认情况下客户端不会主动去找服务器拿公钥,从而导致错误的出现。\[2\]解决这个问题的方法有以下几种:一是启用TLS作为首选机制,确保可用;二是设置AllowPublicKeyRetrieval=True,允许客户端自动从服务器请求公钥;三是使用ServerRSAPublicKeyFile连接字符串设置服务器的RSA公钥。需要注意的是,启用AllowPublicKeyRetrieval=True可能会增加恶意代理执行MITM攻击以获取明文密码的风险,因此默认情况下是禁用的,需要显式启用它。\[3\]
#### 引用[.reference_title]
- *1* *2* [Public Key Retrieval is not allowed解决](https://blog.csdn.net/weixin_55599565/article/details/125140094)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [DBeaver连接时报错:Public Key Retrieval is not allowed Public Key Retrieval is not allowed](https://blog.csdn.net/qq_42971035/article/details/120247453)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)