Skip to content

Could not connect to DB from Node JS but successfully connect from php and phpmyadmin #250

@ashalaenko

Description

@ashalaenko

Hi. I Got a problem. I have a DB and program code in NodeJS for work with this DB. But I got an error :
Access denied for user 'user'@'127.0.0.1' (using password: YES).

But when I tried to connect to this DB from PHP script and from PhpMyadmin all worked correct. I was confused .
So, but when I tried to connect to other DB from NodeJS - all worked correct too. I could not understand what the problem. I tried all options for connection which described in your module but nothing could help me. This is a trace/debug/verbose :

$ node runsimulator.js
<-- HandshakeInitializationPacket
{ protocolVersion: 10,
  serverVersion: '5.5.25-log',
  threadId: 2139504,
  scrambleBuff1: <Buffer 4d 3d 28 4f 36 5f 5c 30>,
  filler1: <Buffer 00>,
  serverCapabilities1: 63487,
  serverLanguage: 8,
  serverStatus: 2,
  serverCapabilities2: 32783,
  scrambleLength: 21,
  filler2: <Buffer 00 00 00 00 00 00 00 00 00 00>,
  scrambleBuff2: <Buffer 78 2e 7a 3e 64 5d 29 4e 30 44 46 70>,
  filler3: <Buffer 00>,
  pluginData: 'mysql_native_password\u0000' }

--> ClientAuthenticationPacket
{ clientFlags: 193487,
  maxPacketSize: 0,
  charsetNumber: 33,
  filler: undefined,
  user: 'user',
  scrambleBuff: <Buffer b8 f4 63 92 6e 65 63 f9 f5 b6 74 ec c8 85 db 4d 7f 29 d5 25>,
  database: 'data_base' }

<-- ErrorPacket
{ fieldCount: 255,
  errno: 1045,
  sqlStateMarker: '#',
  sqlState: '28000',
  message: 'Access denied for user \'user\'@\'127.0.0.1\' (using password: YES)' }

{ [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'127.0.0.1' (using password: YES)] code: 'ER_ACCESS_DENIED_ERROR', fatal: true }
Query error : Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'127.0.0.1' (using password: YES)

There is my code which I used :

var connection = mysql.createConnection('mysql://user:password@127.0.0.1:3306/data_base?debug=true');

    connection.connect(function(err){
        if (err) {
            console.log(err);
        }
    });
    connection.query("SET time_zone='+"+new Date().getTimezoneOffset()/60*(-1)+":00'", function(error, result) {
    if (error) {
        console.log('Query error : '+error);
    }
});

So, I tried use the object style for set params for connect but got the same result. Please help.
Help!

I used your connector and I like it but this situation was confused me and I really need help because I don't know what should do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions