解决MySQL8.0报错Client does not support authentication protocol requested by server…问题


解决MySQL8.0报错Client does not support authentication protocol requested by server; consider upgrading MySQL client问题

原创:丶无殇  2023-10-07


报错内容

在这里插入图片描述

使用node.js连接数据库MySQL 8时候,报错ER_NOT_SUPPORTED_AUTH_MODE,并且提示Client does not support authentication protocol requested by server; consider upgrading MySQL client:客户端不支持服务器请求的身份验证协议;考虑升级MySQL客户端;

报错原因

最新的MySQL模块并未完全支持MySQL 8.0的caching_sha2_password加密方式,而MySQL 8.0中默认仍然是caching_sha2_password加密方式,因此用户认证不通过了。

在这里插入图片描述

如下查询:

mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.02 sec)

在这里插入图片描述

这里的“123456”是你自己的密码

解决方法

直接数据库工具里面修改加密方式mysql_native_password:

在这里插入图片描述

或者通过指令方式修改:

mysql> alter user 'root'@'localhost' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.01 sec)

在这里插入图片描述

数据库连接和关闭都成功,连接问题解决

在这里插入图片描述

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/c7b92d4b4f.html