javascript Node.js & MySQL - 错误:1251 - 客户端不支持服务器请求的认证协议;考虑升级 MySQL 客户端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49991865/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 08:51:51  来源:igfitidea点击:

Node.js & MySQL - Error: 1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

javascriptmysqlnode.jssequelize.js

提问by ifhy

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. 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?

但是当我尝试运行 .js 时,我收到了这个错误。我已经尝试了很多解决方案,包括我经常找到但没有奏效的解决方案。所以现在我不知道该怎么办。有人可以帮助我吗?

Thank you

谢谢

回答by Shimrit Snapir

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'

Worked for me. root password is changed to 'password'

对我来说有效。根密码更改为“密码”

回答by Akshara

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';

回答by Kuldeep Kumar

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”

回答by Guoyong Yi

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,错误解决。