14

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

2
  • What auth modes do you have configured for your server? Commented Apr 24, 2018 at 6:55
  • caching_sha2_password Commented Apr 24, 2018 at 11:40

4 Answers 4

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

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

Sign up to request clarification or add additional context in comments.

3 Comments

This worked for me too. I think this is due to the use of SHA256 for password storage in new version of mysql.
I was working on Docker containers and I needed to change in the query localhost to % because I was connecting to a different hostname. It works!
thanks for your answer, it worked for me and it saves lot of time. thank you.
3

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

2 Comments

It was in fact about changing the plugin to mysql_native_password but not in that way because as I said on my previous post I tried that but the syntax was wrong. I searched on MySQL documentation and I found this: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; And this worked! Thanks for the help though :)
just to clarify, the syntax might be a little different, in my case, it was ... set authentication_string='password', ...
1

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'

Comments

1

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.

1 Comment

Thank you. This was the issue. The environment variable was named USER and wasn't being loaded into the process.env object. I changed its name to MYSQL_USER and it became available and the connection worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.