title: I'm getting unknown database error while connecting to mysql through node.js
body: <p>PS G:\boot&gt; node hello.js
  Example app listening at http://localhost:3000
  G:\boot\node_modules\mysql\lib\protocol\Parser.js:437
  throw err; // Rethrow non-MySQL errors
  ^</p>
  <p>Error: ER_BAD_DB_ERROR: Unknown database 'boot'
  at Handshake.Sequence._packetToError (G:\boot\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
  at Handshake.ErrorPacket (G:\boot\node_modules\mysql\lib\protocol\sequences\Handshake.js:123:18)
  at Protocol._parsePacket (G:\boot\node_modules\mysql\lib\protocol\Protocol.js:291:23)
  at Parser._parsePacket (G:\boot\node_modules\mysql\lib\protocol\Parser.js:433:10)
  at Parser.write (G:\boot\node_modules\mysql\lib\protocol\Parser.js:43:10)
  at Protocol.write (G:\boot\node_modules\mysql\lib\protocol\Protocol.js:38:16)
  at Socket. (G:\boot\node_modules\mysql\lib\Connection.js:88:28)
  at Socket. (G:\boot\node_modules\mysql\lib\Connection.js:526:10)
  at Socket.emit (events.js:376:20)
  at addChunk (internal/streams/readable.js:309:12)
  --------------------
  at Protocol._enqueue (G:\boot\node_modules\mysql\lib\protocol\Protocol.js:144:48)
  at Protocol.handshake (G:\boot\node_modules\mysql\lib\protocol\Protocol.js:51:23)
  at Connection.connect (G:\boot\node_modules\mysql\lib\Connection.js:116:18)
  at Object. (G:\boot\hello.js:22:12)
  at Module._compile (internal/modules/cjs/loader.js:1068:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
  at Module.load (internal/modules/cjs/loader.js:933:32)
  at Function.Module._load (internal/modules/cjs/loader.js:774:14)
  at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
  at internal/main/run_main_module.js:17:47 {
  code: 'ER_BAD_DB_ERROR',
  errno: 1049,
  sqlMessage: &quot;Unknown database 'boot'&quot;,
  sqlState: '42000',
  fatal: true
  }</p>
  <p><strong>code is</strong></p>
  <pre><code>const express = require('express')
  var mysql = require('mysql')
  const bodyParser = require('body-parser')
  const app = express()
  const port = 3000
  // app.use(express.static('css'))
  
  app.use(bodyParser.urlencoded({ extended: false }))
  app.set('view engine', 'pug')
  
  app.get('/', function (req, res) {
    res.sendFile('signup.html', { root: __dirname })
  });
  
  var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '',
    database: 'boot'
  });
  
  connection.connect(function (err) {
    if (err) throw err;
  
    console.log('Connected.........')
  })
  
  connection.end();
  
  app.post('/submit', function (req, res) {
    console.log(req.body);
    res.render('index', {
      title: 'Data saved',
      message: 'Data saved successfully'
    })
  })
  
  app.listen(port, () =&gt;
    console.log(`Example app listening at http://localhost:${port}`)
  )
  ```[enter image description here][1]
  
  
    [1]: https://i.stack.imgur.com/hRNXp.png
  </code></pre>