在编写node接口时,连接mysql总是报错1251,如下:
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
网上查阅到说mysql 默认加密规则是严格加密模式,要修改成普通模式
并使用如下方法:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
// 'password'是你的数据库密码
但是本次工作中并不支持我去修改数据库;
后来在看mysql npm包的文档时发现已经有2年没有更新,于是乎换用了mysql2,完美解决!