前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Node连接Mysql报错:`Client does not support authentication protocol requested by server...'

Node连接Mysql报错:`Client does not support authentication protocol requested by server...'

作者头像
vincentKo
发布2022-09-19 15:12:25
1.4K1
发布2022-09-19 15:12:25
举报
文章被收录于专栏:VK | BLOGVK | BLOG

背景 最近使用Node连接数据库的时候,控制台报错:

代码语言:javascript
复制
Client does not support authentication protocol requested by server; consider upgrading MySQL client

遂寻找了出错的原因 原因 MySQL 8 has supports pluggable authentication methods. By default, one of them named caching_sha2_password is used rather than our good old mysql_native_password (source). It should be obvious that using a crypto algorithm with several handshakes is more secure than plain password passing that has been there for 24 years! Now, the problem is mysqljs in Node (the package you install with npm i mysql and use it in your Node code) doesn't support this new default authentication method of MySQL 8, yet. The issue is in here: https://github.com/mysqljs/mysql/issues/1507 and is still open, after 3 years, as of July 2019. 在网上有看到这样一段描述,翻译过来,大概意思就是 MySQL 8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password,但是在Node中的mysqljs还不支持mysql8默认的新规则。 所以将账户的加密规则改为旧的即可 查看用户信息 select host,user,plugin,authentication_string from mysql.user;

果然,当前的方式是chching_sha2_password 解决方式 账户登录mysql 以root账户为例,这里可以为其他账户 mysql -u root -p 更改root加密规则 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; root就是上一步登录的root账户,当然如果使用其他账户也可以; password替换成你想要修改的密码 更新权限 flush privileges;

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-03-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档