title: node.js mysql error: ECONNREFUSED
body: <p>Why can't I connect to the mysql server?</p>
  
  <p>On the same server an Apache/PHP server is running and it connects without problems!?</p>
  
  <pre><code>var mysql_link = {
      host : 'localhost',
      port : 3308,
      database: 'nodetest',
      user : 'root',
      password : 'xxx'
  };
  
  var connection = mysql.createConnection(mysql_link);
  
  connection.connect(function(err){
      console.log(err);
      if(err != null){
          response.write('Error connecting to mysql:' + err+'\n');
      }
  });
  
  connection.end();
  </code></pre>
  
  <h1>error</h1>
  
  <pre><code>{ [Error: connect ECONNREFUSED]
    code: 'ECONNREFUSED',
    errno: 'ECONNREFUSED',
    syscall: 'connect',
    fatal: true }
  </code></pre>
  
  <h1>update</h1>
  
  <pre><code>root@dyntest-amd-6000-8gb /var/www/node/dyntest # ps ax | grep mysqld
   7928 pts/0    S+     0:00 grep mysqld
  28942 ?        S      0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid
  29800 ?        Sl    17:31 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/lib/mysql/mysql-error.log --open-files-limit=65535 --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
  </code></pre>