title: How can I securely store the IP address, username and password of a database using Node.js?
body: <p>I have Node.js code to connect to a <a href="https://en.wikipedia.org/wiki/MySQL" rel="nofollow noreferrer">MySQL</a> database:</p>
  <pre><code>var mysql = require('mysql')
  var express = require('express')
  var app = express()
  
  var connection = mysql.createPool({
      connectionLimit: 50,
        host     : 'ip',
      user     : 'username',
        password : 'pass',
        database : 'mydb'
  });
  
  
  app.get('/', function(req, resp) {
      connection.getConnection(function(error, tempCont) {
          if(!!error) {
              tempCont.release();
              console.log('Error');
          } else {
              console.log('Connected!');
  
              tempCont.query(&quot;select * from table&quot;, function(error, rows, fields) {
                  tempCont.release();
                  if(!!error) {
                      console.log('Error in the query');
                  } else {
                      resp.json(rows);
                  }
              });
          }
      })
  })
  
  console.log(&quot;listening requests...&quot;)
  app.listen(1337);
  </code></pre>
  <p>How do I secure an IP address, username and password used for connecting to a database so that is not visible in the code or configuration file?</p>