Categories
JavaScript Answers

How to fix Node and MySQL – ER_ACCESS_DENIED_ERROR Access denied for user ‘root’@’localhost’ error?

Spread the love

To fix Node and MySQL – ER_ACCESS_DENIED_ERROR Access denied for user ‘root’@’localhost’ error, we should make sure we connect with the right credentials.

For instance, we write

const mysql = require("mysql");
const connection = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "",
});

to call createConnection with an object with the user userame and password password to the host host.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.