You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JasonWu73
changed the title
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
MySQL 8 身份验证插件
Feb 2, 2020
问题重现
运行一个简单的 Node.js 程序,测试下我们 MySQL 服务器的连通性:
如果我们使用的是 MySQL 8.0.4 及以后的版本,且在没有进行额外配置的情况下,不出意外地我们会得到以下的错误:
这是因为从 MySQL 8.0.4 开始,MySQL 服务器的默认身份验证插件从
mysql_native_password
更改为了caching_sha2_password
,而我们使用的 MySQL 客户端还不支持新版的身份验证插件。所以一个比较简单的解决方案就是将用户的身份验证插件改回mysql_native_password
。问题解决
查看用户所使用的身份验证插件:
上面的结果正验证了我们的猜测,下面我们就将
root
用户的身份验证插件修改为mysql_native_password
:ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root123';
然后再执行我们的 Node.js 代码,访问
http://localhost:5000/users
,就可以得到正确结果了。参考链接
The text was updated successfully, but these errors were encountered: