Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin:egg-mysql报错,提示升级 #4230

Closed
zhenmang opened this issue Mar 23, 2020 · 9 comments
Closed

plugin:egg-mysql报错,提示升级 #4230

zhenmang opened this issue Mar 23, 2020 · 9 comments

Comments

@zhenmang
Copy link

报错如下:
nodejs.ER_NOT_SUPPORTED_AUTH_MODEError: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

环境版本信息

  • Node Version:v12.15.0
  • Egg Version:egg@2.26.0
  • Plugin Name:egg-mysql
  • Plugin Version:egg-mysql@3.0.0
  • Platform:macOS Mojave 10.14.6
  • Mini Showcase Repository:https://github.com/zhenmang/egg-socket.git
  • Mysql Version:mysql-8.0.19-macos10.15-x86_64

详细报错如下:
nodejs.ER_NOT_SUPPORTED_AUTH_MODEError: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at Handshake.Sequence._packetToError (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Connection.js:88:28)
at Socket. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:223:5)
at addChunk (_stream_readable.js:309:12)
--------------------
at Protocol._enqueue (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at PoolConnection.connect (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Connection.js:116:18)
at Pool.getConnection (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Pool.js:48:16)
at /Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:29:7
at new Promise ()
at Pool. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:12:10)
at Pool.ret [as getConnection] (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:56:34)
at Pool.query (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Pool.js:202:8)
at /Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:29:7
sql: select now() as currentTime;
code: "ER_NOT_SUPPORTED_AUTH_MODE"
errno: 1251
sqlMessage: "Client does not support authentication protocol requested by server; consider upgrading MySQL client"
sqlState: "08004"
fatal: true
name: "ER_NOT_SUPPORTED_AUTH_MODEError"
pid: 7013
hostname: 192.168.0.103

2020-03-23 22:43:07,601 ERROR 7013 nodejs.ER_NOT_SUPPORTED_AUTH_MODEError: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at Handshake.Sequence._packetToError (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Connection.js:88:28)
at Socket. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:223:5)
at addChunk (_stream_readable.js:309:12)
--------------------
at Protocol._enqueue (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at PoolConnection.connect (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Connection.js:116:18)
at Pool.getConnection (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Pool.js:48:16)
at /Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:29:7
at new Promise ()
at Pool. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:12:10)
at Pool.ret [as getConnection] (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:56:34)
at Pool.query (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/mysql/lib/Pool.js:202:8)
at /Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/ali-rds/node_modules/pify/index.js:29:7
sql: select now() as currentTime;
code: "ER_NOT_SUPPORTED_AUTH_MODE"
errno: 1251
sqlMessage: "Client does not support authentication protocol requested by server; consider upgrading MySQL client"
sqlState: "08004"
fatal: true
name: "ER_NOT_SUPPORTED_AUTH_MODEError"
pid: 7013
hostname: 192.168.0.103

2020-03-23 22:43:07,601 ERROR 7013 [app_worker] start error, exiting with code:1
[2020-03-23 22:43:07.614] [cfork:master:7010] worker:7013 disconnect (exitedAfterDisconnect: false, state: disconnected, isDead: false, worker.disableRefork: true)
[2020-03-23 22:43:07.614] [cfork:master:7010] don't fork, because worker:7013 will be kill soon
2020-03-23 22:43:07,614 INFO 7010 [master] app_worker#1:7013 disconnect, suicide: false, state: disconnected, current workers: ["1"]
[2020-03-23 22:43:07.615] [cfork:master:7010] worker:7013 exit (code: 0, exitedAfterDisconnect: false, state: dead, isDead: true, isExpected: false, worker.disableRefork: true)
2020-03-23 22:43:07,616 ERROR 7010 nodejs.AppWorkerDiedError: [master] app_worker#1:7013 died (code: 0, signal: null, suicide: false, state: dead), current workers: []
at Master.onAppExit (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/egg-cluster/lib/master.js:510:21)
at Master.emit (events.js:223:5)
at Messenger.sendToMaster (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/egg-cluster/lib/utils/messenger.js:137:17)
at Messenger.send (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/egg-cluster/lib/utils/messenger.js:102:12)
at EventEmitter. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/egg-cluster/lib/master.js:353:22)
at EventEmitter.emit (events.js:228:7)
at ChildProcess. (internal/cluster/master.js:188:13)
at Object.onceWrapper (events.js:313:26)
at ChildProcess.emit (events.js:223:5)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
name: "AppWorkerDiedError"
pid: 7010
hostname: 192.168.0.103

2020-03-23 22:43:07,616 ERROR 7010 [master] app_worker#1:7013 start fail, exiting with code:1
2020-03-23 22:43:07,616 ERROR 7010 [master] exit with code:1
2020-03-23 22:43:07,623 ERROR 7012 [agent_worker] receive disconnect event on child_process fork mode, exiting with code:110
2020-03-23 22:43:07,625 ERROR 7012 [agent_worker] exit with code:110
Error: /Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/egg-bin/lib/start-cluster {"typescript":false,"declarations":true,"workers":1,"baseDir":"/Users/815355586qq.com/Documents/uni-app-project/egg-socket","framework":"/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/egg"} exit with code 1
at ChildProcess. (/Users/815355586qq.com/Documents/uni-app-project/egg-socket/node_modules/common-bin/lib/helper.js:56:21)
at Object.onceWrapper (events.js:313:26)
at ChildProcess.emit (events.js:223:5)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) {
code: 1
}

@hyj1991
Copy link
Member

hyj1991 commented Mar 25, 2020

你的 mysql server 版本是啥?

@bolin-L
Copy link

bolin-L commented Mar 25, 2020

你用的mysql server是 8.0.4以上的吧 mysql 8.0.4 以上版本安装时默认了caching_sha2_pasword的认证方式,但是egg-mysql底层以来的mysqljs目前还没有支持,你只能通过去修改conf文件default_authentication_plugin=mysql_native_password或者降级mysql server

@xuxucode
Copy link
Contributor

或者在创建用户的时候,明确指定 mysql_native_password 认证插件:

CREATE USER 'nativeuser'@'localhost'
IDENTIFIED WITH mysql_native_password BY 'password';

https://dev.mysql.com/doc/refman/8.0/en/sha256-pluggable-authentication.html

@hyj1991 hyj1991 closed this as completed Mar 30, 2020
@JerroldLee
Copy link

你用的mysql server是 8.0.4以上的吧 mysql 8.0.4 以上版本安装时默认了caching_sha2_pasword的认证方式,但是egg-mysql底层以来的mysqljs目前还没有支持,你只能通过去修改conf文件default_authentication_plugin=mysql_native_password或者降级mysql server

conf文件文件的位置在哪?

@yangyankang
Copy link

default_authentication_plugin=mysql_native_password

执行 mysqld --help --verbose | more, 这几个默认位置里找配置文件,读取顺序如下图所示
image

@zhenmang
Copy link
Author

zhenmang commented May 15, 2022 via email

@zchuhui
Copy link

zchuhui commented May 28, 2022

我的解决方法就是创建一个新的账号,然后授权即可:

CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; 
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION; 
FLUSH PRIVILEGES;

@MAX2594
Copy link

MAX2594 commented Nov 23, 2023

如果想用caching_sha2_pasword的方式认证连接有没有办法吖🤔

@zhenmang
Copy link
Author

zhenmang commented Nov 23, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants