最近想要尝试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. Hive中导入Oracle数据错误:Listener refused the connection with the following error: ORA-12505

    问题: 今天往Hive中导入Oracle数据的时候碰到了如下错误:Listener refused the connection with the following error: ORA-12505 ...

  2. 如何在vue-cli 3.x中使用jquery

    由于项目需求要使用jquery,结果各种引用都不济于事. 最后在网上找到了答案,现把它记录一下,给有需要者. 首先下载 jquery. cnpm install jquery --save-dev 方 ...

  3. python笔记7 logging模块 hashlib模块 异常处理 datetime模块 shutil模块 xml模块(了解)

    logging模块 日志就是记录一些信息,方便查询或者辅助开发 记录文件,显示屏幕 低配日志, 只能写入文件或者屏幕输出 屏幕输出 import logging logging.debug('调试模式 ...

  4. keras多层感知机MLP

    肯定有人要说什么多层感知机,不就是几个隐藏层连接在一起的吗.话是这么说,但是我觉得我们首先要自己承认自己高级,不然怎么去说服(hu nong)别人呢 from keras.models import ...

  5. 起步 - 安装 Git

    安装 Git 是时候动手尝试下 Git 了,不过得先安装好它.有许多种安装方式,主要分为两种,一种是通过编译源代码来安装:另一种是使用为特定平台预编译好的安装包. 从源代码安装 若是条件允许,从源代码 ...

  6. 003-结构型-01-适配器模式(Adapter)

    一.概述 将一个类的接口转换成客户期望的另一个接口.适配器模式让那些接口不兼容的类可以一起工作. 1.1.适用场景 已经存在的类,它的方法和需求不匹配时(方法结果相同或相似) 不是软件设计阶段考虑的设 ...

  7. spring boot配置文件、日志配置和代码的多环境配置

    一般项目都逃不掉开发.测试和生产这三套环境,如果每次给这三套环境打包都去改配置,累死不说,还一不留心就出差错.倒不如每套环境各给一套配置来的轻松.上代码: 1.通用配置放在application.pr ...

  8. jQuery学习二

    1.id选择器: // 4.如果页面中多个元素id相同,jquery只会获取第一个id的jquery对象 var jquery = $('#name'); alert(jquery.val()); v ...

  9. 详解Nginx中HTTP的keepalive相关配置

    http keepalive在http早期 ,每个http请求都要求打开一个tpc socket连接,并且使用一次之后就断开这个tcp连接.使用keep-alive可以改善这种状态,即在一次TCP连接 ...

  10. spacemacs:emacs和vim结合,大杀器。vim党转emacs

    结合本人基础,做下述结论.不一定准确.  基础:  1. vim操作和高级操作,熟悉.使用的spf13-vim.  2. emacs以前学过,但是按键太累,相比vim简直难受.  3. emacs命令 ...