Database connection failed: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authenticatio

使用node 中的 mysql 包 连接 mysql 报错
Database connection failed: Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

具体报错截图:

在这里插入图片描述

原因

最新的mysql模块并未完全支持MySQL 8的“caching_sha2_password”加密方式,而“caching_sha2_password”在MySQL 8中是默认的加密方式。因此,下面的方式命令是默认已经使用了“caching_sha2_password”加密方式,该账号、密码无法在mysql模块中使用。

解决方法:

修改加密方式

1、use mysql;

2、alter user 'root'@'localhost' identified with mysql_native_password by '你的数据库密码';

3、flush privileges;

注:如果采用的是命令行窗口,确认是否是以管理员的身份打开。

猜你喜欢

转载自blog.csdn.net/qq_46123200/article/details/143336454