ER_NOT_SUPPORTED_AUTH_MODE:客户端不支持服务器请求的身份验证协议.考虑升级MySQL客户端
问题描述:
nodejs中使用的mysql问题
const mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '123456789',
database : 'userdata'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err);
return;
}
console.log('connected as id ' + connection.threadId);
});
错误: ER_NOT_SUPPORTED_AUTH_MODE:客户端不支持服务器请求的身份验证协议;考虑升级MySQL客户端
答
出现相同的问题.
Install MySQL Workbench
执行以下查询:MySQL Workbench中的ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456789';
Execute this query: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456789';
in MySQL Workbench
返回到Node.js,然后尝试再次运行该文件.它应该起作用,至少对我有用.
Head back over to Node.js and try running the file again. It should work, at least it did for me.