title: ER_NO_DB_ERROR: No database though database is present
body: <p>I am learning to create application using node js , I am connecting node js to mysql, the connection is successful , but after that when I am giving "select" command from node file it's throwing "ER_NO_DB_ERROR: No database selected" this error.
  Below are my files :</p>
  
  <p>config.js</p>
  
  <pre><code>module.export ={
  server : "localhost/phpmyadmin/",
  port : "3306",
  database : "newdb",
  username : "root",
  password : ""
  }
  </code></pre>
  
  <p>connection.js </p>
  
  <pre><code>var dbConfig = require("./config")
  var sqlInst = require("mysql")
   var con = {};
  module.exports.createCon = function(callback){
  
   con = sqlInst.createConnection(dbConfig);
  
  con.connect(function(err){
  
      if(err)        
      {
          console.error(err);  
         // callback(err);
      }
      else{      
          console.log("connected");
      }
  
  })
  
  module.exports.instSql = function(callback){
      let sql = "SELECT * FROM `producdesc`";
      con.query(sql,(err,result)=&gt;{
      if(err){
        console.log(err);
        res = err;
      }
      else {
          res = result;
      }
  
      });
    //  return res;
  }
  
  }
  </code></pre>
  
  <p>server.js file:</p>
  
  <pre><code>const exp = require("express");
  var connect = require("./connection")
  const app = exp();
  
  app.listen('3000',()=&gt;{
  console.log('server strated at port 3000');
  })
  
  app.get('/connect',(req,res)=&gt;{
  console.log("hello");
  connect.createCon();
  res.send("connected to database");
  })
  
  app.get('/show',(req,res)=&gt;{
  let prodRes ;
  console.log("in show");
  prodRes=connect.instSql();
     res.send(prodRes);
    })
  </code></pre>
  
  <p>The error comes only when I try to "<a href="http://localhost:3000/show" rel="nofollow noreferrer">http://localhost:3000/show</a>" , the database and the table are present in the database.</p>
  
  <p>Could someone please let me know the issue</p>