title: Cannot Connect to AWS RDS MySQL Database Using Express JS
body: <p>I am trying to connect to my Amazon RDS cloud database using Express framework. My server.js connection looks as follows:</p>
  
  <pre><code>const express = require('express');
  var bodyParser = require('body-parser')
  const mysql = require('mysql');
  const cors = require('cors');
  const port = process.env.PORT || 3300;
  const connection = mysql.createConnection({
  host     : 'endpoint-of-my-rds-database.amazonaws.com',
  user     : 'user',       
  password : 'password',           
  database : 'database', 
  port: 3300,                
  socketPath: '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'
  });
  
  const app = express();
  app.use(cors());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  
  connection.connect(function(err) {
      if(err) throw err;
  
      console.log("connected to database");
  })
  </code></pre>
  
  <p>After running <code>node server.js</code> I get the following standard error:</p>
  
  <pre><code>Access denied for user 'root'@'localhost' (using password: YES)
  </code></pre>
  
  <p>I am able to connect to my cloud database with the same credentials using MySQL Workbench. Also, I can connect to my local MySQL database through Express by changing credentials to those of my local MySQL database.</p>
  
  <p>Researching online, it appears that this error is due to invalid credential, but, as I've mentioned, I can connect to my RDS database through Workbench with no issues. It is only Express that seems to give me trouble. Will be happy to provide additional info. Any help will be appreciated. Thank you in advance.</p>