0

Could someone tell what error "ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client" means?

My code:

var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "user",
  password: "password",
  database: 'database'
});

con.connect(function(err) {
  if (err) throw 'THE ERROR IS: ' + err;
  console.log("Connected!");
});

2 Answers2

0

In the link that I sent for you, was added this property: insecureAuth : true.

var con = mysql.createConnection({
  host: "localhost",
  user: "user",
  password: "password",
  database: 'database',
  insecureAuth : true

});
  • Try this: `sudo mysql -u root -p` `ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'ChoosePassword';` `FLUSH PRIVILEGES;` – Abraao Duarte Jan 29 '21 at 20:35
0

I also faced the same issue but the error got resolved by using mysql2 instead of mysql. so type

npm install mysql2 

in your terminal. and update your code with

const mysql = require("mysql2");
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103