title: Can't connect to localhost database from node.js server
body: <p>Been having a lot of trouble trying to connect to to my localhost database. I've tried using the <a href="https://npmjs.org/package/mysql" rel="nofollow noreferrer">mysql</a> and <a href="https://npmjs.org/package/mysql-simple" rel="nofollow noreferrer">mysql-simple</a> node modules but in both cases I just can't get it to connect.</p>
  <p>Here's what I used with the 'mysql' module:</p>
  <pre><code>var mysql = require('mysql');
  var connection = mysql.createConnection({
    host     : 'localhost',
    port     : '8000',
    user     : 'uber',
    password : 'pass',
  });
  
  connection.connect(function(err) {
        if (err) throw err;
  
        console.log('Connection Successful');
  });
  
  
  connection.query('USE someDB', function(err) {
    if (err) throw err;
  
    console.log('Query Successful');
  });
  </code></pre>
  <p>And here' what I used with the 'mysql-simple' module:</p>
  <pre><code>var database = require('mysql-simple');
  database.init('uber', 'pass', 'mysql', 'localhost', 8000);
  
  database.querySingle('SELECT Host FROM user', function(err, results) {
      if (err) {
          console.log('error fetching some active users: ' + err);
          return;
      }
      log('Query Successful');
      for (var i = 0; i &lt; results.length; i++)
          console.log('got active user ' + results[i]);
  }
  </code></pre>
  <p>In both cases, when I run my node.js server, it never logs that its connected. I've tried replacing localhost with '127.0.01' and creating a new user to make sure the password is correct, but to no avail. Why isn't it connecting?</p>
  <p>Thanks</p>