Human Cyborg Relations Human Cyborg Relations - 9 months ago 74
Node.js Question

Access Denied for User (NodeJS & MySQL)

I'm trying to connect to a database that I have up on my domain. I've created a user called public_guests which can access this database.

I'm using NodeJS to create a connection but I get the following error.

ER_ACCESS_DENIED_ERROR: Access denied for user

The error is followed by my IP address etc.

Here is my code:

mysql = require("mysql");

var connection = mysql.createConnection({
host: "",
username: "public_guests",

console.log("Couldn't connect :( Error: " + error);
} else {
console.log("Connected successfully~!");

I've never used a database before, so I'm expecting this to be a really stupid mistake somewhere.


As I think, it's not the problem of Node.js.

it's permissions issue which user has at particular IP address, and in the error message is stated:

Access denied for user @some IP

So try to give your root permission for IP where your Node.js instance is running port xxx.xx.xx.xx.