Reputation: 91
I have been trying to connect to remote database using NodeJS where I have also added a user and given all the permission.
I am getting this Error:
ER_ACCESS_DENIED_ERROR: Access denied for user.
Please help. This is the code
const mySql = require("mysql");
//creating DataBase connection
const con = mySql.createConnection({
host: process.env.SQL_HOST,
user: process.env.SQL_USER,
password: process.env.SQL_PASSWORD,
database: process.env.SQL_DATABASE
});
//connect to DataBase
con.connect(function(err)
{
if(err)
{
console.log("Error Connecting to Database: "+err);
}
else
{
console.log("Connected to Database: Successful");
}
});
Upvotes: 1
Views: 1759
Reputation: 91
I Found the answer, Add to remote Access mySql in your Cpanel your local IP so that you can access it. Thanks
Upvotes: 3