场景复现
在使用nodejs访问mysql查询数据的时候报错:
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
解决方案
$ sudo mysql -u root
mysql> ALTER USER the_user IDENTIFIED WITH mysql_native_password BY 'the_password';
问题分析
mysql插件不支持mysql8.0的用户验证方式,通过mysql命令将当前用户降级即可。
参考连接
https://github.com/mysqljs/mysql/issues/2499