0

I am new to using node.js and mysql, I have a simple script that uses node to log me into a mysql server.

var mysql = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : ''
});
connection.connect(function(err) 
{
  if (!err)
    console.log('Connected');
  else
    console.log('Error connection');
    console.log(err);
});

When my xampp mysql server is running it returns connected, however when xampp is turned off and the mysql server notifier is running it returns this error.

"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 }" I used the installer for windows found on the mysql site. I am running windows 10, and it is installed directly into the C drive of my computer.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Nicholas
  • 11
  • 3

3 Answers3

0

can you try by executing following command:

use mysql;
update user set authentication_string=password(''), plugin='mysql_native_password' where user='root';
Anshuman Jaiswal
  • 5,352
  • 1
  • 29
  • 46
0

I didn't know what was MySQL Notifier so I searched on Google. According to the documentation I found here (www.mysql.com), MySQL Notifier only notifies for changes on your system and connection to your MySQL Server.

It means that this utility tool is not a MySQL server, you can't use it like it was. You need a running MySQL server (launched by xamp).

There are many ways to run a MySQL server without xamp:

Anyway, your server version mismatches with your client version, which is here your mysql Node.js library. The two versions work with each other but the authentication method seems to have changed.

Which version of it do you use? Did you try to update it? npm update mysql

Best solution maybe here: There is a closed issue on this subject in the mysqljs GitHub repository where Andrey Sidorov advices to

allow to use insecure auth: https://github.com/mysqljs/mysql#connection-options insecureAuth option.

Source: https://github.com/mysqljs/mysql/issues/1574

Option description:

  • insecureAuth: Allow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)

https://github.com/mysqljs/mysql#connection-options

You can try to set this option to true:

var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'root',
  password : '',
  insecureAuth: true
});

Just a little thing, "xamp" stands for "LinuX Apache MySQL PHP" (so you're using "wamp" -> "Windows Apache MySQL PHP").

Paul Rey
  • 1,270
  • 1
  • 15
  • 26
0

If you are running MySQL 8.0 then you are probably facing the same issue (and will be able to solve it with the same solution) described here.

ruiquelhas
  • 1,905
  • 1
  • 17
  • 17