jjzjj

javascript - Node.js 和 MySQL - 错误 : 1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client

coder 2023-05-30 原文

现在我只有这个代码:

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 时,我得到 this error .我已经尝试了很多解决方案,包括我发现的 more often but it didn't work .所以现在我不知道该怎么办。有人可以帮帮我吗?

谢谢

最佳答案

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

为我工作。 root密码改成'password'

关于javascript - Node.js 和 MySQL - 错误 : 1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49991865/

有关javascript - Node.js 和 MySQL - 错误 : 1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client的更多相关文章

随机推荐