I\'m trying to connect my NodeJs application with a mysql database but its not connecting for some reason.
I did install the mysql npm like this (typed this in comma
Instead of
mysqlConnection.connect((err) => {
use
connection.connect((err) => {
if(!err)
console.log('Database is connected!');
else
console.log('Database not connected! : '+ JSON.stringify(err, undefined,2));
});
[Here the is tutorials reference for the code]1
For your mysql error:
Execute the following query in MYSQL Workbench:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
Try connecting using node after you do so.