0

I am using mysql and node.js. I am trying get a simple connection, but getting this weird error. the code i am using is this

var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'userlogin'
});
connection.connect();

and here is the error i am getting:

and here is the error i am getting

here is some details about the server:

here is some details about the server

sticky bit
  • 36,626
  • 12
  • 31
  • 42

1 Answers1

1

Have you tried executing this in the workbench worked for me

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
Ashton
  • 174
  • 11
  • This is because caching_sha2_password is introduced in MySQL 8.0, but the Node.js version is not implemented yet. – Ashton Sep 17 '18 at 00:55
  • if this or any answer has solved your question please consider [accepting it](https://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Ashton Sep 17 '18 at 01:17