title: connect MySql database in WHM(phpmyadmin) to node.js
body: <p>As a team, we are using node.js to setup the database connection with Mysql in Cpanel.</p>
  
  <p>I did not make the database, but I know the host, user,password, database name, and port. However, in app.js, although I put all the code needed to connect to the database, it fails all the time.</p>
  
  <p>Here is my code in app.js.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var mysql = require('mysql');
  
  // creating a connection to the db
  var con = mysql.createConnection({
    host: 'localhost',
    user: 'myUsername',
    password: 'myPassword',
    database: 'myDatabase',
    port:3306
  });
  
  con.connect(function(err) {
    if(err){
      console.log('Error connecting to DB');
      return;
    }
    console.log('Connection established');
  });</code></pre>
  </div>
  </div>
  </p>