mysql8.0 报错Public Key Retrieval is not allowed

当使用SpringBoot的JDBC连接MySQL8.0.33时,可能会遇到PublicKeyRetrieval报错。这通常由于新版本的加密方式caching_sha2_password引起。解决方法包括在URL中添加allowPublicKeyRetrieval=true参数,或更改用户加密规则为mysql_native_password。两种方法都可以有效解决问题。

 springboot  jdbc链接mysql8.0.33时报错

com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not allowed

查看下用户的密码

 密码方式默认采用了 8.0 新特性 caching_sha2_password,可以用mysql_native_password来替代 就不会有问题了

处理方式1,添加参数allowPublicKeyRetrieval=true

 

jdbc:mysql://localhost:3306/ds?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8

处理方式2,修改加密规则为mysql_native_password

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

或者修改 plugin 

update mysql.user set plugin='mysql_native_password' where user='root';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值