最近想要尝试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. 【SpringBoot/MVC】从Oracle下载百万条记录的CSV

    工程下载地址:https://files.cnblogs.com/files/xiandedanteng/CsvDownloadOracle20191110-2.rar 画面: 核心代码: 控制器: ...

  2. vuecli3集成easyui

    思路是这样的,首先要将jquery设置成全局,然后就可以正常使用easyUI了. jquery安装命令: npm install --save jquery jquery-easyui安装命令: np ...

  3. python 中 dict 的另一种用法

    python 中 dic另一种用法 描述 Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值. 语法 dict={} dict.get(k1,Non ...

  4. 创建IDOC

    第一步:WE31 创建IDOC所包含的字段. 第二步:WE30 创建IDOC 把Segment分配给IDOC 第三步:WE81 创建信息类型 第四步:WE82 把IDOC类型与信息类型对应. 第五步: ...

  5. MySQL 5.6 my.cnf优化后的标准配置(4核 16G Centos6.5 x64)

    [client] port = 3306 socket = /var/lib/mysql/mysql.sock [mysql] #这个配置段设置启动MySQL服务的条件:在这种情况下,no-auto- ...

  6. Mac PhpStorm 2017 破解

    官网下载链接: https://www.jetbrains.com/zh/phpstorm/specials/phpstorm/phpstorm.html?utm_source=baidu&u ...

  7. Core Data 的使用

    一.概念 1.Core Data 是数据持久化存储的最佳方式 2.数据最终的存储类型可以是:SQLite数据库,XML,二进制,内存里,或自定义数据类型 在Mac OS X 10.5Leopard及以 ...

  8. 【Leetcode_easy】804. Unique Morse Code Words

    problem 804. Unique Morse Code Words solution1: class Solution { public: int uniqueMorseRepresentati ...

  9. (生鲜项目)07. api view实现商品列表页

    第一步: 环境配置 1. DRF官网: https://www.django-rest-framework.org/ 仔细查看自己当前的python版本以及django版本是否支持DRF, 然后就看看 ...

  10. vue中添加less配置,用于计算div高度

    需求:左边垂直的菜单栏高度设置为 100% - 导航栏的高度(3.6rem) 首先,从vue-cli脚手架里的安装的webpack模板中并没有less的依赖配置,得自己手动添加安装 安装命令::npm ...