nodejs连接mysql报错:Client does not support authentication protocol requested by server; consider upgrad
程序员文章站
2022-06-12 22:45:30
...
由于本人是前端,mysql只是偶尔做一下小项目会用到,大概一年没有用了。
今天用mac通过brew下载了一个8.0.12版本的mysql;然后用egg进行连接,egg是阿里封装的一个nodejs框架。
下载到本地的mysql;初始密码我是留空的。
所以在nodejs项目中配置mysql连接数据的时候我的password=’’;
结果报错了:
Client does not support authentication protocol requested by server; consider upgrad
我怀疑是MySQL密码的问题;于是我到网上找了很多种修改密码方法:
//开启mysql服务
mysql.server start
//进入mysql
mysql -u root -p
//修改密码方案1(错)
USE mysql SET PASSWORD FOR 'root'@'localhost' = OLD_PASSWORD('密码');
//修改密码方案2(错)
UPDATE mysql.user SET Password = OLD_PASSWORD('密码')WHERE Host = 'localhost' AND User = 'root';
//修改密码方案3(对)
USE mysql;
ALTER USER 'root'@'localhost'IDENTIFIED WITH mysql_native_password BY '密码';
//重启
FLUSH PRIVILEGES;
修改密码后的nodejs项目的配置文件
client: {
// host
host: 'localhost',
// 端口号
port: '3306',
// 用户名
user: 'root',
// 密码
password: '123456',
// 数据库名
database: 'blog',
},
最后用了方案3终于连接上了;记住你运行nodejs项目时一定要先将mysql的服务打开,不然也是连不上的。
推荐阅读
-
mysql Client does not support authentication protocol requested by server; consider upgrading MySQL
-
解决Navicat连接MySQL时“Client does not support authentication protocol requested by server; consider upgrading MySQL client”的问题
-
连接8.0.15mysql 报错 client does not support authentication protocol requested by server ,consider upgra
-
nodejs连接mysql报错:Client does not support authentication protocol requested by server; consider upgrad
-
MySQL8.0报错Client does not support authentication protocol requested by server; consider upgrading My
-
MySql 链接报错“Client does not support authentication protocol requested by server; consider upgradin”
-
node连接数据库报错Client does not support authentication protocol requested by server; consider upgrading M
-
关于nodejs报错Client does not support authentication protocol requested by server; consider upgrading My
-
MySql8.0,使用Navicat连接时报错:Client does not support authentication protocol requested by server;consider
-
navicate连接MySQL出现报错client does not support authentication protocol requested by server consider ...