title: Cannot Connect nodejs to mysql
body: <p>I am running <code>Node.js 0.10.31</code> on windows and my <code>mySQL 5.5.35</code> on virtual-box ubuntu running on 192.168.2.150. Now to connect node js to mysql i have used following connector :</p>
  
  <p><a href="https://github.com/felixge/node-mysql" rel="nofollow">https://github.com/felixge/node-mysql</a></p>
  
  <p><strong>Code :</strong></p>
  
  <pre><code>var mysql = require('mysql');
  var connection = mysql.createConnection({
  host : '192.168.2.150',
  user : 'root',
  password : '*****',
  port : 3306
  });
  
  connection.connect(function(err) {
  if (err) {
  console.error('error connecting: ' + err.stack);
  return;
  }
  
  console.log('connected as id ' + connection.threadId);
  });
  
  
  connection.query('SELECT 1', function(err, rows) {
  // connected! (unless `err` is set)
  console.log(err, rows);
  });
  </code></pre>
  
  <p>In my.cnf file <code>bind address</code> is 0.0.0.0. Moreover, in the user table i have given permission to all database to <code>root@192.168.2.150</code>. But, still i am not able to connect from node to mysql and it gives the following error. 
  I have even tried to the Node js 0.8.2 version but still it doesn't work. can anyone point out the error?</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code> error connecting: Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'
  192.168.2.99' (using password: YES)
      at Handshake.Sequence._packetToError (G:\Coding_Zone\NodeJs_Work\Output\node
  _modules\mysql\lib\protocol\sequences\Sequence.js:48:14)
      at Handshake.ErrorPacket (G:\Coding_Zone\NodeJs_Work\Output\node_modules\mys
  ql\lib\protocol\sequences\Handshake.js:101:18)
      at Protocol._parsePacket (G:\Coding_Zone\NodeJs_Work\Output\node_modules\mys
  ql\lib\protocol\Protocol.js:271:23)
      at Parser.write (G:\Coding_Zone\NodeJs_Work\Output\node_modules\mysql\lib\pr
  otocol\Parser.js:77:12)
      at Protocol.write (G:\Coding_Zone\NodeJs_Work\Output\node_modules\mysql\lib\
  protocol\Protocol.js:39:16)
      at Socket.Connection.connect (G:\Coding_Zone\NodeJs_Work\Output\node_modules
  \mysql\lib\Connection.js:82:28)
      at Socket.EventEmitter.emit (events.js:88:17)
      at TCP.onread (net.js:397:14)
      --------------------
      at Protocol._enqueue (G:\Coding_Zone\NodeJs_Work\Output\node_modules\mysql\l
  ib\protocol\Protocol.js:135:48)
      at Protocol.handshake (G:\Coding_Zone\NodeJs_Work\Output\node_modules\mysql\
  lib\protocol\Protocol.js:52:41)
      at Connection.connect (G:\Coding_Zone\NodeJs_Work\Output\node_modules\mysql\
  lib\Connection.js:109:18)
      at Object.&lt;anonymous&gt; (G:\Coding_Zone\NodeJs_Work\Output\mySqlTest.js:9:12)
      at Module._compile (module.js:449:26)
      at Object.Module._extensions..js (module.js:467:10)
      at Module.load (module.js:356:32)
      at Function.Module._load (module.js:312:12)
      at Module.runMain (module.js:492:10)
      at process.startup.processNextTick.process._tickCallback (node.js:244:9)
  { [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'192.168.2.99' (
  using password: YES)]
    code: 'ER_ACCESS_DENIED_ERROR',
    errno: 1045,
    sqlState: '28000',
    fatal: true } undefined
  </code></pre>
  
  <p><strong>Update :</strong></p>
  
  <p>I did try with other users also and granted them full permission in the database. But still wasn't able to resolve the error. 
  But the strange thing is that i am able to connect with the mysql Client </p>