node连接mysql8.0,再用navicat客户端连接出现client does not support authentication protocol requested by server。

直接上解决方法,我的mysql版本8.0以上,出现这个问题
node连接mysql8.0,再用navicat客户端连接出现client does not support authentication protocol requested by server。
代码:
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘password’ PASSWORD EXPIRE NEVER; 其中‘password’是你现在的密码,这行目的是更改加密规则

ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;其中‘password’是你想要改的密码
node连接mysql8.0,再用navicat客户端连接出现client does not support authentication protocol requested by server。
然后输入FLUSH PRIVILEGES; #用来刷新权限

这时候用新密码连接就成功了
node连接mysql8.0,再用navicat客户端连接出现client does not support authentication protocol requested by server。

温情小提示:最好用管理员权限打开cmd