错误:ER_NOT_SUPPORTED_AUTH_MODE:客户端不支持服务器请求的身份验证协议.考虑升级MySQL客户端
我正在尝试使用以下代码连接到MySQL数据库.
Am trying to connect to MySQL database using the below code.
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();
但是出现以下错误:
错误:ER_NOT_SUPPORTED_AUTH_MODE:客户端不支持 服务器请求的认证协议;考虑升级MySQL 客户
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.
I have MySQL-installer-community-8.0.11.0 installed on my local.
我需要安装其他连接器来连接数据库吗?
Do I need to install any other connectors to connect to the database?
昨天我的mysql容器与mysql + nodejs遇到了同样的问题. 到目前为止,我还没有找到修复程序,但是它与新的mysql版本(8.X)有关系. 在我重新安装了版本5的mysql之后,一切对我来说都很好.
I had the same problem yesterday with my docker container with mysql + nodejs. I didnt found so far a fix but it has something todo with the new mysql version(8.X). After i reinstalled mysql with version 5 everything worked well for me.