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

被折叠的 条评论
为什么被折叠?



