I am building an Expo App in ' MacOS Mojave 10.14.6 ' using mysql database.I want to create forgot password page which needs to send email notification to user to reset password.So I am writing a Node.js program which will connect to Mysql.But I am getting error.
Below is the Node.js Database program:
database.js:
var mysql=require('mysql2');
var connection=mysql.createConnection({
host:'localhost',
user:'root',
password:'',
database:'*******'
});
connection.connect((err) => {
if(!err)
console.log('Database is connected!');
else
console.log('Database not connected! : '+ JSON.stringify(err, undefined,2));
});
module.exports = connection;
After running the above program,I am getting the below error:
Database not connected! : {
"code": "ER_ACCESS_DENIED_ERROR",
"errno": 1045,
"sqlState": "28000",
"sqlMessage": "Access denied for user 'root'@'localhost' (using password: NO)"
}
I tried to alter the password in Mysql Workbench using the below command :
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Test123'; But it gives an error as :
Incorrect usage of ALTER and SYSTEM USER.
I am able to connect to database from Mysql Workbench with a username and password.Can anyone say where I am going wrong.Thanks in Advance.