Rupesh
Rupesh

Reputation: 890

NodeJS MySQL Client does not support authentication protocol

When I am trying to connect with mysql 8.0 I am getting this error. How can I fix this ?

code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlMessage: 'Client does not support authentication protocol requested by server; 
consider upgrading MySQL client',
sqlState: '08004',
fatal: true

Upvotes: 25

Views: 70812

Answers (4)

yang qinglin
yang qinglin

Reputation: 9

npm install mysql2  

this is a good way to solve the problem

Upvotes: -1

Coder's Channel
Coder's Channel

Reputation: 1

I also encountered the said error, what I did first was to remove the mysql using npm remove mysql, then install the mysql2, then edit the server.js to change the mysql to mysql2 then after saving my changes I restarted the server, and the error is gone.

Upvotes: 0

AN German
AN German

Reputation: 801

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

FLUSH PRIVILEGES;

"password" is that you have to change the password you already have or you will modify it for a new one

Upvotes: 13

TIAGO SILVA
TIAGO SILVA

Reputation: 531

Try change the password as below:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'your new password'; 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your new password';

Upvotes: 53

Related Questions