I am attempting to connect to mySQL through a NodeJS file, but I receive the following error:
{ Error: ER_ACCESS_DENIED_ERROR: Access denied for user \'root\
The problem is not with the mysql user authentication. It just that you have to grant your node application to access mysql db. I was facing the same issue earlier.I added the port number on which my node application is running.And its working perfectly fine now.
Also user:"root" was written as username:"root" . Be careful with the spellings.
const mysqlConnection = mysql.createConnection({
host: "localhost",
user: "root",
password: "Pass@123",
database: "employees",
port:"3000",
multipleStatements: true
});
I am using mysql version "mysql": "^2.18.1".