nodejs连接mysql数据库,报错Client does not support authentication protocol requested by server的解决方法
最近想要尝试nodejs连接本地数据库,往全栈方向做一个小小的尝试,于是下载了一个 MySQL8.0,发现Navicat连接不上,结果就下载了mysql自身的Workbench,继续使用。
然而,难受的是,在我连接下载安装好nodejs、express等一系列东西之后。
// 数据库连接配置
module.exports = {
mysql: {
host: '127.0.0.1',
user: 'root',
password: '123456',
database: '*******',//数据库名称
port: '3306'
}
}
然而运行之后报了这个错误

发现好像还是和mysql版本有关系,然后就开始搜索解决。
查看大神的结论是:
MySQL8.0版本的加密方式和MySQL5.0的不一样,连接会报错。
解决方法如下:
- 通过命令行进入解压的mysql根目录下。
- 登陆数据库
mysql -uroot -p - 输入root的密码
Enter password: ****** - 更改加密方式(原样拷贝到命令窗中)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; - 更改密码:该例子中 123456为新密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; - 刷新:
mysql> FLUSH PRIVILEGES;
/如果报错ERROR 1396 (HY000): Operation ALTER USER failed for ‘root’@’%’:
则是远程访问权限不正确,先选择数据库,查看一下再更改:
mysql> use mysql;
Database changed
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)
文章参考:https://blog.csdn.net/XDMFC/article/details/80263215
转载: https://blog.csdn.net/airdark_long/article/details/82588064
nodejs连接mysql数据库,报错Client does not support authentication protocol requested by server的解决方法的更多相关文章
- navicat连接远程数据库报错'client does not support authentication protocol requested by server consider ...'解决方案
[1.cmd终端连接远程mysql数据库方法] mysql -uhello -pworld -h192.168.1.88 -P3306 -Dmysql_oa mysql -u用户名 -p密码 -h ...
- 安装mysql8.0.17时候报错1251-Client does not support authentication protocol requested by server; consider upgrading MySQL client
当mysql数据库安装时候选择的是加密密码时候,用navicat连接时候报错1521,这时候可以cmd之后登陆mysql执行下列代码就可以了 代码: mysql> alter user root ...
- Navicat连接Mysql8.0失败:Client does not support authentication protocol requested by server...
今天Mysql服务无法启动,看着网上的教程稀里糊涂的就用命令mysqld --initialize给初始化了,结果就是以前的表都没了,重新安装后,Navicat无法连接数据库 解决方法如下: 意思是直 ...
- Navicat连接Mysql报错:Client does not support authentication protocol requested by server;
Navicat连接Mysql报错:Client does not support authentication protocol requested by server: 刚安装Mysql,想用Nav ...
- egg 连接 mysql 的 docker 容器,报错:Client does not support authentication protocol requested by server; consider upgrading MySQL client
egg 连接 mysql 的 docker 容器,报错:Client does not support authentication protocol requested by server; con ...
- navicat 连接 mysql 出现Client does not support authentication protocol requested by server解决方案
安装了navicat 和 mysql,结果最后在navicat中连接mysql时,出现了如下错误提示: Client does not support authentication protocol ...
- node mysql问题:Client does not support authentication protocol requested by server; consider upgrading MySQL client!
node后台 mysql处理模块(版本:2.16.0) 执行connect方法时报错: Client does not support authentication protocol requeste ...
- Client does not support authentication protocol requested by server; consider upgrading MySQL client
出现错误 Client does not support authentication protocol requested by server; consider upgrading MySQL c ...
- MySQL Server8.0版本时出现Client does not support authentication protocol requested by server
MySQL Server8.0版本时出现Client does not support authentication protocol requested by server 解决方法: 1.roo ...
随机推荐
- Tosca TestCases: Update all,Checkin all,Checkout,Checkout Tree
#记录一下TestCases Module 红框里面这几个button的功能 #Update all 从数据库里把别人最新checkin的东西给拽出来查看,也就是拿最新版本 #Checkin all ...
- sppNet论文学习
Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition 深度神经网络中用于视觉识别的空间金字塔池化 ...
- Oracle存在则更新,不存在则插入应用-merge
转: Oracle存在则更新,不存在则插入应用-merge 2017年01月11日 14:15:26 周星猩 阅读数 11354更多 分类专栏: Oracle 版权声明:本文为博主原创文章,遵循C ...
- osgText::Text osg字体
#ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include<iostream> #include <osgV ...
- 阶段5 3.微服务项目【学成在线】_day17 用户认证 Zuul_14-网关-介绍网关及搭建网关工程
4 Zuul网关 4.1 需求分析 网关的作用相当于一个过虑器.拦截器,它可以拦截多个系统的请求. 本章节要使用网关校验用户的身份是否合法. 4.2 Zuul介绍 什么是Zuul? Spring Cl ...
- JSONP实现Ajax跨域请求
前言 由于浏览器存在同源策略的机制,所谓同源策略就是阻止从一个源(域名,包括同一个根域名下的不同二级域名)加载的文档或者脚本获取/或者设置另一个源加载的文档属性. 但比较特别的是:由于同源策略是浏览器 ...
- Day4作业:蛋疼CRM系统
先上流程图,还得27寸4K显示器,画图各种爽: ReadMe: 运行程序前的提示: 1.抱歉,你得装prettytable模块...... 2.还得抱歉,如果shell中运行,最好把字体调得小点,表格 ...
- Treeview控件如何获得子节点的所有父节点的名称
Delphi或c++ 的treeview控件,比如一个节点上面有个父节点,这个父节点上面还有一个父节点,如何获得这两个父节点的名字呢?请给出实现代码 先定义一个nodevarnode:TTreeNod ...
- WPF引入OCX控件
(方法一) https://www.cnblogs.com/guaniu/archive/2013/04/07/3006445.html (方法二) 1.先注册OCX控件:(有的把OCX 控件封装到E ...
- Spring Cloud(6.3):搭建OAuth2 Resource Server
配置web.xml 添加spring-cloud-starter-security,spring-security-oauth2-autoconfigure2个依赖. <!-- Spring c ...