NodeJS MySQL客户端不支持身份验证协议。

24

我在尝试连接到mysql 8.0时遇到了这个错误。我该怎么解决?

code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlMessage: 'Client does not support authentication protocol requested by server; 
consider upgrading MySQL client',
sqlState: '08004',
fatal: true

服务器请求的认证协议以及你使用的协议 - 这就是你应该查看的地方。 - Kamil Gosciminski
@Rupesh:同时更改plugin字段,因为它被设置为“auth_socket”。 use mysql; update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';请查看此链接:点击这里 - Manav
解决方案 https://dev59.com/MnI95IYBdhLWcg3w5SWh#36234358 - prashant0205
@Manav 我正在使用mysql 8.0.11,我尝试了以下命令: mysql> use mysql; Database changed mysql> update user set password=PASSWORD("helloworld") where User='root'; 但是它显示:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '("helloworld") where User='root'' at line 1 - Rupesh
请在此处查看答案:https://dev59.com/7lUL5IYBdhLWcg3wbne4#74458804 - Lorraine R.
显示剩余3条评论
3个回答

50

请尝试按以下方式更改密码:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'your new password'; 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your new password';

2
非常好的答案!这解决了我的问题!您能否请解释一下为什么这样做有效? - Jessica
4
MySQL 8.0 默认采用 caching_sha2_password 作为身份验证插件,而不是 MySQL 5.7 的默认选项 mysql_native_password。大多数客户端都支持后者,因此您需要明确允许给定用户使用该身份验证方式: ALTER USER 'user' IDENTIFIED WITH mysql_native_password BY 'password' - iki

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

FLUSH PRIVILEGES;

"password"指的是您需要更改您已有的密码或修改为一个新密码


1
你可以将Mysql降级到5.7来解决这个问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接