title: Nodejs Failing to Connect To WampServer MySQL Database
body: <p>I am new to web development and I have started working on Nodejs.
  I am trying to connect to the MySQL Server on <strong>port 3308</strong>, <em>WampServer</em> but instead I always get connected to localhost server.
  To ensure that I am using right ports and hostnames, I have tried to setup the connection using MYSQL Workbench and it worked!
  But still, I am not able to figure out how to connect with mysql driver.</p>
  
  <pre><code>const sql = require('mysql');
  var con = sql.createConnection({
     host: '127.0.0.1:3308',
     user: 'root',
     password: '',
     port: 3308
  });
  con.connect(function (err) {
      if (err) throw err;
      console.log("Connected!");
  });
  
  createDatabaseQuery= theQ =&gt;{
     return "CREATE DATABASE ".concat(theQ);
  }
  
  con.query(createDatabaseQuery('nodedb'), function(err) {
     if (err) {
       throw err;
  
     }
  });
  </code></pre>
  
  <p>Here is my output:</p>
  
  <pre><code>[Running] node "c:\Users\Asus\WebstormProjects\Impulse\MySQLTest.js"
  c:\Users\Asus\WebstormProjects\Impulse\MySQLTest.js:8
      if (err) throw err;
               ^
  
  Error: connect ECONNREFUSED 127.0.0.1:3306
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16)
      --------------------
      at Protocol._enqueue (c:\Users\Asus\WebstormProjects\Impulse\node_modules\mysql\lib\protocol\Protocol.js:144:48)
      at Protocol.handshake (c:\Users\Asus\WebstormProjects\Impulse\node_modules\mysql\lib\protocol\Protocol.js:51:23)
      at Connection.connect (c:\Users\Asus\WebstormProjects\Impulse\node_modules\mysql\lib\Connection.js:116:18)
      at Object.&lt;anonymous&gt; (c:\Users\Asus\WebstormProjects\Impulse\MySQLTest.js:7:5)
      at Module._compile (internal/modules/cjs/loader.js:1158:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
      at Module.load (internal/modules/cjs/loader.js:1002:32)
      at Function.Module._load (internal/modules/cjs/loader.js:901:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
      at internal/main/run_main_module.js:18:47 {
    errno: 'ECONNREFUSED',
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 3306,
    fatal: true
  }
  
  [Done] exited with code=1 in 1.198 seconds
  </code></pre>