[英]Node.js & MySQL - Error: 1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client
Right now I have only this code: 现在我只有这个代码:
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'root', 'passwd', {
host: 'localhost',
dialect: 'mysql',
// http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
operatorsAliases: false
});
sequelize
.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});
But when I try to run the .js I get this error . 但是当我尝试运行.js时,我得到了这个错误 。 I have already tried a lot of solutions out there, including the one I found more often but it didn't work .
我已经尝试了很多解决方案,包括我经常发现的解决方案, 但它没有用 。 So right now I don't know what to do.
所以现在我不知道该怎么做。 Can somebody help me?
有人能帮助我吗?
Thank you 谢谢
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
Worked for me. 为我工作。 root password is changed to 'password'
root密码更改为'password'
Changing the plugin to mysql_native_password might solve the problem! 将插件更改为mysql_native_password可能会解决问题!
use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';
Basically when I was trying to connect to Mysql Query Browser at that time I as facing the issue. 基本上当我试图连接到Mysql查询浏览器时,我正面临着这个问题。
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'
Worked for me. 为我工作。 root password is changed to 'root'
root密码更改为“root”
I found out that I was caused by incorrect parameters. 我发现我是由不正确的参数引起的。
{ database: 'abc',
username: undefined,
password: 'efsefs',
}
username is undefined, but the error is "consider upgrading MySQL client" So modify the user name to be true, the error resolved. 用户名未定义,但错误是“考虑升级MySQL客户端”因此修改用户名为true,错误已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.