还是这个问题Client does not support authentication protocol requested by server

来源:6-6 API对接mysql(博客列表)

Narmo

2021-06-18

我按照网上的方法修改了,然后npm run dev没有问题,但是node ./bin/www.js就报错了,还是那个not support的错误。

node ./bin/www.js执行结果:

 ~/coding/nodejs/node-blog  node ./bin/www.js
Listening on 8000
/Users/zhengjihan/coding/nodejs/node-blog/node_modules/mysql/lib/protocol/Parser.js:437
      throw err; // Rethrow non-MySQL errors
      ^

Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
    at Handshake.Sequence._packetToError (/Users/zhengjihan/coding/nodejs/node-blog/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Handshake.ErrorPacket (/Users/zhengjihan/coding/nodejs/node-blog/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
    at Protocol._parsePacket (/Users/zhengjihan/coding/nodejs/node-blog/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/Users/zhengjihan/coding/nodejs/node-blog/node_modules/mysql/lib/protocol/Parser.js:433:10)

npm run dev执行结果:

 ~/coding/nodejs/node-blog  npm run dev

> blog@1.0.0 dev
> cross-env NODE_ENV=dev nodemon --inspect=9229 ./bin/www.js

[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node --inspect=9229 ./bin/www.js`
Debugger listening on ws://127.0.0.1:9229/ab31438d-0e98-4a93-b97b-12ca3eedae9e
For help, see: https://nodejs.org/en/docs/inspector
Listening on 8000

这是为什么呢?

写回答

2回答

双越

2021-06-19

哦,抱歉我上次看错了。


`npm run dev`可以了,但是直接用`node ./bin/www.js`不行 ——  你这个问题很怪异,我还没遇到过呢。package.json 中 dev 的具体命令是啥?

0
6
Narmo
最后一行:[nodemon] app crashed - waiting for file changes before starting...
2021-06-21
共6条回复

双越

2021-06-18

mysql 配置的问题,很常见。可以百度搜一下“mysql Client does not support authentication”

先自己试着解决一下,搞不定的话再来回复我。

0
1
Narmo
网上搜到的方法全都是 ``` alter user 'root'@'%' identified by 'password' password expire never; alter user 'root'@'%' identified with mysql_native_password by 'xxx'; flush privileges; ``` 这个我已经操作过了,所以`npm run dev`可以了,但是直接用`node ./bin/www.js`不行
2021-06-18
共1条回复

Node.js+Express+Koa2+Nest.js 开发服务端

从入门到实战,一站式掌握 Node.js+Express+Koa2

4050 学习 · 2006 问题

查看课程