使用nodejs连接数据库时提示"Client does not support authentication protocol requested by server; "的错误解决办法
报错:在使用nodejs连接数据库时,提示"‘Client does not support authentication protocol requested by server; consider upgrading MySQL client’"
分析:造成上述问题的原因是nodejs未完全支持mysql8.0的认证协议
解决方法:重新修改用户密码
// 1.登录数据库
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p
//2.更改密码,复制如下命令
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '要修改的密码';
/*
*如果报错"ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'"要查看数据库的访问权限,可能是%
*
*/