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 ...
随机推荐
- Eclipse自动生成作者、日期注释等功能设置 (转载)
原文地址:http://blog.sina.com.cn/s/blog_4080505a0101guoh.html 在使用Eclipse 编写Java代码时,自动生成的注释信息都是按照预先设置好的格式 ...
- OSError: image file is truncated (28 bytes not processed)
解决办法: 在代码中添加两行 from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True
- 015-命令行下载安装brew
一.brew 1.安装Homebrew 安装命令: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/inst ...
- 29 Flutter Dialog AlertDialog 、SimpleDialog、showModalBottomSheet、showToast
pubspec.yaml fluttertoast: ^ Dialog.dart import 'package:flutter/material.dart'; import 'package:flu ...
- 算法习题---4-5IP网络(Uva1590)
一:题目 给出m(1到10000之间)个IP地址,求他们最小的网络号和子网掩码 (一)样例输入 3 表示要获取的IP地址个数 194.85.160.177 IP地址 194.85.160.183 19 ...
- CentOS7下搭建zabbix监控(二)——Zabbix被监控端配置
Zabbix监控端配置请查看:CentOS7下搭建zabbix监控(一)——Zabbix监控端配置 (1).在CentOS7(被监控端)上部署Zabbix Agent 主机名:youxi2 IP地址: ...
- IDEA的查询引用、调用关系图的功能(转)
转自: http://www.cnblogs.com/ghj1976/p/5382455.html Eclipse的"Call Hierarchy"可以查看一个Java方法或类成员 ...
- 【Leetcode_easy】696. Count Binary Substrings
problem 696. Count Binary Substrings 题意:具有相同个数的1和0的连续子串的数目: solution1:还不是特别理解... 遍历元数组,如果是第一个数字,那么对应 ...
- Linux - 对比net-tools与iproute2
简介 net-tools包含ifconfig.route.arp和netstat等命令行工具,用于管理和排查各种网络配置. 起源于BSD TCP/IP工具箱,旨在配置老式Linux内核的网络功能. 自 ...
- SSRS 2016 Forms Authentication
SSRS 2016 comes with completely new report manager web interface and implementing form authenticatio ...