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 ...
随机推荐
- VIM快速掌握
vi/vim 基本使用方法 vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令.由于对Unix及Linux系统的 ...
- 001-http-总览、文件配置、常用http client、http连接池
一.概述 http请求项目搭建:地址:https://github.com/bjlhx15/common-study.git 中的common-http 主要针对post请求中的,form表单[app ...
- Foxmail找回密码 及 Wireshark 使用【我】
Foxmail中设置了密码,但是时间长忘了,现在要用,需要弄出来 首先,安装 Wireshark 抓包工具 一路下一步即可, 安装完确保这个图标表示的组件已经安装: 如果没有安装,在Wireshark ...
- webpack——Modules && Hot Module Replacement
blog:JavaScript Module Systems Showdown: CommonJS vs AMD vs ES2015 官网链接: Modules 官网链接:Hot Module Rep ...
- Springboot集成MapperFactory(ma.glasnost.orika.MapperFactory)类属性复制
一.导入Jar() gradle方式 compile group: 'ma.glasnost.orika', name: 'orika-core', version: '1.5.1' maven方式 ...
- WebDriver介绍
Fetching a Page driver.get("http://www.google.com") Locating UI Elements (WebElements) By ...
- HTML、CSS之查遗补漏
inline-block3个额外像素宽度问题 先看下例子: Title .sp{ /*border: 1px solid lightcoral;*/ display: inline-block; he ...
- springboot项目自定义注解实现的多数据源切换
一.主要依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spri ...
- 【嵌入式硬件Esp32】ESP32学习之在windows下搭建eclipse开发环境
一.所需工具 由于项目要用ESP32模块进行开发,折腾了下集成开发环境,现将过程记录下来,以便需要的人使用.其中需要的有交叉编译工具,esp-idf示例代码以及C/C++版的eclipse. 交叉编译 ...
- SMAP数据产品介绍与下载方法
1 SMAP(Soil Moisture Active and Passive)数据介绍 SMAP baseline science data products在下面的表格中展示,这些数据产品可以从两 ...