0

I have a nodejs app which get some data from mysql database in same server. I am using xampp in ubuntu 16.04. The database connection from php and phpmyadmin is fine and working nicely. But my nodejs page can not connect to mysql database and giving me

code: 'ER_ACCESS_DENIED_ERROR', errno: 1045, sqlMessage: "Access denied for user 'root'@'x.x.x.x' (using password: YES)", sqlState: '28000', fatal: true

I have given all grants to root user in mysql database.

My nodejs connection is as follows:

const mysql = require('mysql');
const moment = require('moment');
var mycon = mysql.createPool({
    connectionLimit: 100,
    host: 'x.x.x.x',
    user: 'root',
    password: 'myPass',
    database: 'myDatabase',
    multipleStatements: true 
});

I am using node version 14.13.0 . Any suggestion regarding this painful situation?

Enayet Hossain
  • 187
  • 1
  • 4
  • 14
  • Could you please try with password='' with empty – Codebrekers Oct 03 '20 at 05:22
  • May be, this link will help you https://stackoverflow.com/questions/40477625/nodejs-mysql-er-eccess-denied-error-access-denied-for-user-rootlocalhost – Codebrekers Oct 03 '20 at 05:23
  • Hello, I have tried all the variations mentioned in the link above... but i m getting same error again and again.... i changed the user to something else but getting error for user root only. very frustrated situation – Enayet Hossain Oct 03 '20 at 06:43
  • insted of x.x.x.x, can you please try localhost – Codebrekers Oct 03 '20 at 07:30
  • check this link https://stackoverflow.com/questions/18496540/node-js-mysql-connection-pooling/18496936 – Codebrekers Oct 03 '20 at 07:32
  • I checked with 'localhost' and also 127.0.0.1 instead of x.x.x.x but still getting same error.... very strangely it always points to root@x.x.x.x even i changed the username to another user with root privileges. – Enayet Hossain Oct 03 '20 at 08:14

0 Answers0