我正在尝试使用以下代码连接到 MySQL 数据库。
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'pass',
database : 'my_db',
insecureAuth : true
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
connection.end();
但出现以下错误:
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
我在本地安装了 MySQL-installer-community-8.0.11.0。
我是否需要安装任何其他连接器才能连接到数据库?
最佳答案
昨天我的 docker 容器和 mysql + nodejs 遇到了同样的问题。 到目前为止我还没有找到修复方法,但它与新的 mysql 版本 (8.X) 有关。 在我用第 5 版重新安装 mysql 后,一切都对我有用。
关于mysql - 错误 : ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50149307/