最近想要尝试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的不一样,连接会报错。 
解决方法如下:

    1. 通过命令行进入解压的mysql根目录下。
    2. 登陆数据库 
      mysql -uroot -p
    3. 输入root的密码 
      Enter password: ******
    4. 更改加密方式(原样拷贝到命令窗中) 
      mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
    5. 更改密码:该例子中 123456为新密码 
      mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
    6. 刷新: 
      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的解决方法的更多相关文章

  1. 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 ...

  2. 安装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 ...

  3. Navicat连接Mysql8.0失败:Client does not support authentication protocol requested by server...

    今天Mysql服务无法启动,看着网上的教程稀里糊涂的就用命令mysqld --initialize给初始化了,结果就是以前的表都没了,重新安装后,Navicat无法连接数据库 解决方法如下: 意思是直 ...

  4. Navicat连接Mysql报错:Client does not support authentication protocol requested by server;

    Navicat连接Mysql报错:Client does not support authentication protocol requested by server: 刚安装Mysql,想用Nav ...

  5. 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 ...

  6. navicat 连接 mysql 出现Client does not support authentication protocol requested by server解决方案

    安装了navicat 和 mysql,结果最后在navicat中连接mysql时,出现了如下错误提示: Client does not support authentication protocol ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 设计自用的golang日志模块

    设计自用的golang日志模块 golang的原生日志模块不能满足需求,而开源的第三方包,也不完全够用.用户较多的logrus,却没有rotate功能,这已经是众所周知的.对于运维来说,当然是希望日志 ...

  2. golang基于当前1.9版本进行源码编译升级到1.10

    一.起因 golang出了最新的1.10版本,而刚出的vgo也是需要基于该最新版本的.为了测试vgo,因此需要将我的v1.9升级到v1.10版本. 安装过golang的同学都知道,golang常用的有 ...

  3. matlab中x.^2与x^2有什么区别?

    .^2是矩阵中的每个元素都求平方,^2是求矩阵的平方或两个相同的矩阵相乘,因此要求矩阵为方阵,且看下面的例子x=1:4x = 1 2 3 4 x.^2 ans = 1 4 9 16 x^2 Error ...

  4. 转:android DownloadManager: java.lang.SecurityException: Invalid value for visibility: 2

    1.问题描述 今天使用Android系统的DownloadManager进行下载操作时,爆了如下所示的错误: java.lang.RuntimeException: Unable to start s ...

  5. socket服务端开发之测试使用threading和gevent框架

    socket服务端开发之测试使用threading和gevent框架 话题是测试下多线程和gevent在socket服务端的小包表现能力,测试的方法不太严谨,也没有用event loop + pool ...

  6. CentOS7下搭建zabbix监控(一)——Zabbix监控端配置

    zabbix 是一个基于 WEB 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案.zabbix 能监视各种网络参数,保证服务器系统的安全运营:并提供灵活的通知机制以让系统管理员快速定位 ...

  7. (十一)Centos之帮助命令

    帮助命令man  (manual) 比如我们可以看下man命令的解释 [root@localhost ~]# man man MAN(1)                               ...

  8. curl 的用法指南

    简介 curl 是常用的命令行工具,用来请求 Web 服务器.它的名字就是客户端(client)的 URL 工具的意思. 它的功能非常强大,命令行参数多达几十种.如果熟练的话,完全可以取代 Postm ...

  9. laravel中redis pipeline用法说明

    $res = Redis::pipeline(function($pipe) use($params) { for ($i = 0; $i < 1000; $i++) { $pipe->g ...

  10. 925. Long Pressed Name

    题目链接:https://leetcode.com/problems/long-pressed-name/description/ Example 1: Input: name = "ale ...