Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 249
ifhy Avatar asked Apr 24 '18 00:04

ifhy


1 Answers

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

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

like image 56
Shimrit Snapir Avatar answered Sep 20 '22 02:09

Shimrit Snapir