我在用 MySQL数据库 连接 node.Js 的时候,发生的错误:

const mysql = require('mysql')// 创建连接对象
const con = mysql.createConnection({host: 'localhost',user: 'root',password: '123456',database: 'myblog'
})// 开始连接
con.connect()// 执行 sql 语句
const sql = `update users set realname="李四2" where username="lisi";`
con.query(sql, (err, result) => {if (err) {console.error(err)return}console.log(result)
})// 关闭连接
con.end()

报的大致的错误:

 r.js:80throw err; // Rethrow non-MySQL errors^Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL clientat Handshake.Sequence._packetToError (C:\Users\mysql-

解决方案:

  1. 如果你有 MYSQL Workbench 的话, 可以直接在里面使用 如下的命令: (注意你的表操作行为)
1.ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourRootPassword';
-- or
CREATE USER 'foo'@'%' IDENTIFIED WITH mysql_native_password BY 'bar';
-- then
FLUSH PRIVILEGES;

2.你可以打开 mysql 自带的命令行工具 或者 命令行:

$ mysql -u root -p
Enter password: (enter your root password)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';
mysql> FLUSH PRIVILEGES;
mysql> quit

到这里你可以重新启动的服务,你就会看你的数据库正在连接成功。

转载于:https://my.oschina.net/u/3520255/blog/3033878

MySQL 8.0 - Client does not support authentication protocol requested by server....相关推荐

  1. SQLyog连接MYSQL时报错 Client does not support authentication protocol requested by server; consider upgra

    之前安装MYSQL8.0的时候安装的是绿色版,在cmd中配置完所有参数之后,在连接SQLyog的时候却报出了以下错误 翻译一下大致的意思为:客户端不支持服务器请求的身份验证协议:考虑升级MYSQL客户 ...

  2. “1251 – Client does not support authentication protocol requested by server;consider upgrading MySQL

    本文由 比特飞 原创发布,欢迎大家踊跃转载. 转载请注明本文地址:"1251 – Client does not support authentication protocol reques ...

  3. Navicat连接MySQL8.0版本时出现Client does not support authentication protocol requested by server;报错的问题解决办法

    Windown系统下 遇到 Navicat连接MySQL8.0版本时出现Client does not support authentication protocol requested by ser ...

  4. nodejs连接mysql报错:Client does not support authentication protocol requested by server; consider upgrad

    由于本人是前端,mysql只是偶尔做一下小项目会用到,大概一年没有用了. 今天用mac通过brew下载了一个8.0.12版本的mysql;然后用egg进行连接,egg是阿里封装的一个nodejs框架. ...

  5. 解决: Client does not support authentication protocol requested by server; consider upgrading MySQL

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 1. 在服务器上把 mysql 装好后,运行起来. 2. navicat 死活连接不上,在网上查说是 ...

  6. 使用NodeJS连接到MySQL数据库Client does not support authentication protocol requested by server; consider upg

    使用NodeJS连接到MySQL数据库时,运行项目,出现如下错误: throw err; // Rethrow non-MySQL errors^Error: ER_NOT_SUPPORTED_AUT ...

  7. nodejs连接mysql数据库,报错Client does not support authentication protocol requested by server的解决方法

    nodejs连接mysql数据库,报错Client does not support authentication protocol requested by server的解决方法 参考文章: (1 ...

  8. Client does not support authentication protocol requested by server; consider upgrading MySQL client

    错误一 Communications link failure due to underlying exception 这说明客户端连接数据库失败,是网络都连不上,不是密码错误连不上,需要检查ip.p ...

  9. Client does not support authentication protocol requested by server;consider upgrading MySQL

    Client does not support authentication protocol requested by server;consider upgrading MySQL 在测试node ...

最新文章

  1. 发布一个用于WinCE的矢量图控件
  2. Web性能测试需监控的IIS性能指标
  3. vue使用echarts图表
  4. sql并行查询oracle,oracle 查看并行sql语句的并行数量
  5. css圆角box(宽度自适应)(百度知道挖出)
  6. 安装Nginx到linux服务器(Ubuntu)详解
  7. 验证码的旋转与放缩代码
  8. python-78:对日期格式进行处理
  9. Java枚举介绍_java枚举使用详细介绍及实现
  10. 脚本小子福利:安卓远控木马直接生成
  11. 计算机那种专业包括vr,VR技术的大学专业有哪些
  12. pandas(一) Series和DataFrame
  13. 生物特征认证和识别市场现状及未来发展趋势
  14. c语言函数传递坐标值,C语言中,函数间数据传递的方式有三种,即用返回值、参数、全局变量。...
  15. #420 Div2 Problem B Okabe and Banana Trees (math 暴力枚举)
  16. GTK 框架(Frames)
  17. IP协议首部详细分析
  18. 百度云 文字识别 身份证识别
  19. 刁生富:《重估:人工智能与人的生存》
  20. 如何直观的理解机器学习PR曲线和ROC曲线?

热门文章

  1. 加快使用Google的CDN网站访问速度
  2. 桐梓县春晖行动志愿者协会开展环保捡拾垃圾志愿服务活动
  3. Java抽象工厂模式详解
  4. [转]google工具大全
  5. React获取router路由路径里的相关信息
  6. 零售商贩mysql表设计:收货地址表 用户表(关联起来)
  7. 安卓10拨号流程梳理
  8. Git仓库从零到熟练(图文超级详细)
  9. cas多系统集成统一认证
  10. 主成分分析——数据中心化与标准化处理