在nest项目中使用typeorm连接MySQL时,明明配置了TypeOrmModule.forRoot(),却在运行项目时始终报错
问题描述
会提示连不上db
ERROR [TypeOrmModule] Unable to connect to the database ERROR [ExceptionHandler] ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
原因分析:
问题在于Node(mysql)尚不支持MySQL 8的这种新的默认身份验证方法
参考:stackoverflow MySQL 8.0 - 客户端不支持服务器请求的身份验证协议
解决方案:
把mysql更换为mysql2
yarn remove mysql yarn add mysql2



