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

有些话、适合烂在心里 提交于 2019-12-09 15:19:58

问题


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?

Thank you


回答1:


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

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




回答2:


Changing the plugin to mysql_native_password might solve the problem!

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



回答3:


Basically when I was trying to connect to Mysql Query Browser at that time I as facing the issue.

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

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




回答4:


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.



来源:https://stackoverflow.com/questions/49991865/node-js-mysql-error-1251-client-does-not-support-authentication-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!