ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; ...

koa2访问mysql的时候,出现如下错误:

server error { Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

原因分析,不同版本的node访问mysql时候,账号的加密方式不同。因为同样程序,在另外一台机器上就没有问题,差异就是node、mysql的版本和这台机器不同。

解决办法:在这台机器上,以root登录到mysql中,执行如下两个命令

alter user '用户名'@'localhost' identified with mysql_native_password by '密码';

flush privileges;

执行完成后,恭喜您,koa2就能正常访问mysql了。

你可能感兴趣的:(ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; ...)