在 node 环境下运行 mysql 由于版本不兼容会报如下错误:
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
...
code: ‘ER_NOT_SUPPORTED_AUTH_MODE‘,
errno: 1251,
sqlMessage: ‘Client does not support authentication protocol requested by server; consider upgrading MySQL client‘,
其他博客会告诉你, 由于 nodejs 和 mysql 8.0 版本 不兼容什么的, 改这个
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘一堆可能不生效的代码‘;
flush privileges;
但是我这里不奏效,索性
npm i mysql8.0 -S
搞定!!!