title: How to connect to local mariadb server with node.js
body: <p>I'm trying to connect to a local mariadb server using node.js. When I try connecting I get the error: </p>
  
  <p>"Error: (conn=8, no: 1045, SQLState: 28000) Access denied for user 'root'@'localhost' (using password: NO)"</p>
  
  <p>I am not sure why this is, as I have the password set when I make the connection, and I can log into the mysql server using the root password with</p>
  
  <pre><code> mysql -u root -p
  </code></pre>
  
  <p>This is what my code looks like:</p>
  
  <pre><code>var mysql = require('mariadb');
  
  var con = mysql.createConnection({
          host: "localhost",
          user: "root",
          password: "8pJcpe/h0h_%",
          port: 3306
          })
          .then(conn =&gt; {
                  console.log("connected" + conn.threadId);
          })
          .catch(err =&gt; {
                  console.log("got error " + err);
          });
  </code></pre>
  
  <p>I have also tried it with port 3307, and get this error:
  "Error: connect ECONNREFUSED 127.0.0.1:3307"</p>
  
  <p>When I try to use the port I am using to ssh into the server, I get this different error:
  " Error: (conn=-1, no: 45009, SQLState: 08S01) socket has unexpectedly been closed"</p>
  
  <p>I am new to this and I could use some help. Thanks.</p>