NodeJS/mySQL - ER_ACCESS_DENIED_ERROR Access denied for user 'root'@'localhost' (using password: YES)
I have the same problem, I solved it by changing the password to empty string.
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: ''
});
Create new user (instead of using root) fixed my problem.
mysql> CREATE USER 'new_user'@'%' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
Then grant:
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'new_user'@'%' WITH GRANT OPTION;
Then change the credentials:
var connection = mysql.createConnection({
host : 'The mysql IP',
port : 'The mysql Port',
user : 'new_iser',
password : 'new_user_pass',
database : 'database-name'
});
Try adding a port field:
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
port: 3307
});