完美解决:MySQL8报错:Public Key Retrieval is not allowed

已解决:MySQL8报错:Public Key Retrieval is not allowed

目录

1.问题描述

 2.解决过程

方案一:

方案二:


1.问题描述

连接MySQL数据库的时候,报错内容如下:“Public Key Retrieval is not allowed”。

 2.解决过程

mysql 8.0 默认使用 caching_sha2_password 身份验证机制 (即从原来mysql_native_password 更改为 caching_sha2_password。)

从 5.7 升级 8.0 版本的不会改变现有用户的身份验证方法,但新用户会默认使用新的 caching_sha2_password 。 客户端不支持新的加密方式。 修改用户的密码和加密方式。

方案一:

在命令行模式下进入mysql,输入以下命令:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

或者 

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

然后就可以正常连接了。

方案二:

在配置数据源的时候直接将属性allowPublicKeyRetrieval设置为true即可

 把我工作中遇到的问题和解决的问题的过程记录下来,同时希望也可以帮到大家!

猜你喜欢

转载自blog.csdn.net/white0718/article/details/131790493