egg-mysql报错:Client does not support authentication protocol requested by server; consider upgradi...

 使用 egg-mysql 的时候报了这个一个错误❌:

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

原因是:

mysql server是 8.0.4以上的吧 mysql 8.0.4 以上版本安装时默认了caching_sha2_pasword的认证方式,但是egg-mysql底层以来的mysqljs目前还没有支持

我这里用的解决方案,就是创建一个新的用户,并授权 mysql_native_password,代码如下:

CREATE USER 'test2'@'%' IDENTIFIED WITH mysql_native_password BY '66668888';

GRANT ALL PRIVILEGES ON *.* TO 'test2'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;


搞定。

你可能感兴趣的:(egg-mysql报错:Client does not support authentication protocol requested by server; consider upgradi...)