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

brgchamk  于 2021-06-24  发布在  Mysql
关注(0)|答案(4)|浏览(376)

现在我只有以下代码:

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);
  });

但是当我尝试运行.js时,我得到了这个错误。我已经尝试了很多解决方案,包括我经常找到的那个,但都不管用。所以现在我不知道该怎么办。有人能帮我吗?
谢谢您

jbose2ul

jbose2ul1#

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

为我工作。根密码更改为“password”

baubqpgj

baubqpgj2#

基本上,当我当时正试图连接到mysql查询浏览器时,我发现我面临着这个问题。

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

为我工作。根密码更改为“root”

rdrgkggo

rdrgkggo3#

我发现我是由错误的参数引起的。

{ database: 'abc',
  username: undefined,
  password: 'efsefs',
}

用户名未定义,但错误是“考虑升级mysql客户端”,因此修改用户名为true,错误得到解决。

efzxgjgh

efzxgjgh4#

将插件更改为mysql\u native\u密码可能会解决这个问题!

use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';

相关问题