当前位置: 代码网 > it编程>数据库>Mysql > 登录MySQL时出现Authentication plugin ‘caching_sha2_password‘ reported error错误的解决方案

登录MySQL时出现Authentication plugin ‘caching_sha2_password‘ reported error错误的解决方案

2024年12月13日 Mysql 我要评论
登录mysql时出现authentication plugin 'caching_sha2_password' reported error: authentication requi

登录mysql时出现authentication plugin 'caching_sha2_password' reported error: authentication requires secure connection.错误

错误原因

错误 error 2061 (hy000): authentication plugin 'caching_sha2_password' reported error: authentication requires secure connection 指出在尝试使用 caching_sha2_password 身份验证插件连接到 mysql 服务器时,由于需要安全连接而未能成功。这通常发生在禁用 ssl 的情况下,因为 caching_sha2_password 插件默认要求通过 ssl/tls 加密的连接来保证安全性。

解决方法

启用ssl

如果您希望保持使用 caching_sha2_password 身份验证插件,那么您需要在 mysql 服务器和客户端之间启用 ssl 连接。这通常涉及到配置 mysql 服务器的 ssl 证书,并确保客户端在连接时使用这些证书。

您可以在 mysql 服务器的配置文件(my.cnf 或 my.ini)中设置 require_secure_transport=on 来强制要求所有连接都使用 ssl/tls。然后,您需要正确配置 ssl 证书,并重启 mysql 服务。

在客户端,您可以通过指定 --ssl-mode=required(或其他适当的 ssl 模式)来确保使用 ssl 连接。

更改身份验证插件

如果您不希望使用 ssl,您可以考虑将 mysql 用户帐户的身份验证插件更改为 mysql_native_password。这可以通过在 mysql 服务器上执行 alter user 命令来实现。

首先记事本打开my.ini配置文件,将下图中所标红的内容删掉,并重启mysql

然后使用mysql自带的工具进行登录

然后更改用户的身份验证插件为mysql_native_password

例如,要将 root 用户的身份验证插件更改为 mysql_native_password,您可以执行以下 sql 命令:

alter user 'root'@'localhost' identified with mysql_native_password by '您的密码';  
flush privileges;

更改后,您应该能够使用旧的身份验证方法(不需要 ssl)连接到 mysql 服务器。 

然后记事本打开my.ini文件,然后按下图所示添加配置

注意:是在[mysqld]下面添加   skip_ssl    记住是 skip_ssl ,不要忘记下划线!!!

此时再次使用如下命令进行查看

然后登录,就能够成功登录了

以上就是登录mysql时出现authentication plugin ‘caching_sha2_password‘ reported error错误的解决方案的详细内容,更多关于登录mysql出现caching_sha2_password的资料请关注代码网其它相关文章!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com