nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra
作者:mmseoamin日期:2023-12-27

场景:nodeJs express框架下使用MySQL数据库,正常与建立MySQL的,因为自己曾把MySQL的默认端口3306改为了3307,引起了一系列错误~

这里建立链接时,特意加上了port:3307,不然会默认找3306端口连 

nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第1张

 参数没问题后,还是有报错

nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第2张

问题:报错Client does not support authentication protocol requested by server; consider upgrading MySQL client

中文意思就是:客户端不支持服务器请求的身份验证协议,考虑升级mysql客户端

这里的根本原因是你安装了8.0版本以上的MySQL,密码加密方式发生了变化所以低版本的navicat不能进行不能自动适配,所以简单的方法就是升级navicat客户端,或者是去手动修改密码规则。

 解决方法:

方法一:

下载新版本的navicat for mysql即可

方法二:

1. 找到你的MySQL安装路径,进入bin目录下

nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第3张

2. 在地址栏输入cmd进行命令行

nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第4张

 3. 输入命令mysql -u root -p ,回车

nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第5张

4. 输入你的密码,回车 

 nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第6张

 5. 要是你的端口就是默认的3306,可以忽略这一段,直接看序号7;因为我不是3306,就报错了。

nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第7张

6. 需要换一个语句:mysql -u root -P 3307 -h 127.0.0.1 -p   回车

填3307的地方就是你的端口号。然后继续输入你的密码,回车

nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第8张

7. 接着依次输入两条命令

  • 这里最后的root就是你修改后的密码,根据自己的需求更改 
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; 
    •  刷新权限
      FLUSH PRIVILEGES; 

      nodeJS MySQL 连接报错Client does not support authentication protocol requested by server; consider upgra,第9张

       完成,重新连接下试试就行了~

      参考文章:Navicat新建连接报错1251Client does not support authentication protocol requested by server解决方法 - 知乎