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';