title: How to remote access MySQL database locally from my computer(through Node.js app) without SSH?
body: <p>I have a mysql server running on ec2 instance. I also have a Node.js app running locally from where I want to connect to my mysql database running on the ec2 instance. I'm using this following code to connect:</p>
  <pre><code>const mysql = require('mysql2/promise');
  
  const mysqlHost = config.host;
  const mysqlUser = config.mysql_user;
  const mysqlPassword = config.mysql_password;
  const mysqlDb = config.mysql_db;
  const mysqlPort = config.mysql_port;
  /*
  *
  * Connection Options
  *
  * */
  const options = {
      connectionLimit: config.connection_pool,
      host: mysqlHost,
      user: mysqlUser,
      password: mysqlPassword,
      database: mysqlDb,
      port: mysqlPort,
      multipleStatements: true,
      Promise: bluebird,
  };
  
  /*
  *
  * Pool
  *
  * */
  logger.warn({ mysqlHost, mysqlDb }, 'Establishing MySQL Connection Pool');
  const pool = mysql.createPool(options);
  </code></pre>
  <p>Now, it doesn't connect to the instance and gives this error:</p>
  <blockquote>
  <p>Unhandled rejection Error: connect ECONNREFUSED</p>
  </blockquote>
  <p>I'm able to ssh into the mysql database through MySQL Workbench and it's working fine.
  Also, I have set the Inbound rules to ALL traffic and from anywhere so there's no problem from AWS side.</p>
  <p>I read a lot about it and here are my findings:
  Edit the my.cnf file in mysql to bind it to the IP of the host computer (which I tried but not able to do it...throwing error everytime)
  Here is my.cnf file</p>
  <pre><code>#
  # The MySQL database server configuration file.
  #
  # You can copy this to one of:
  # - &quot;/etc/mysql/my.cnf&quot; to set global options,
  # - &quot;~/.my.cnf&quot; to set user-specific options.
  # 
  # One can use all long options that the program supports.
  # Run program with --help to get a list of available options and with
  # --print-defaults to see which it would actually understand and use.
  #
  # For explanations see
  # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
  
  #
  # * IMPORTANT: Additional settings that can override those from this file!
  #   The files must end with '.cnf', otherwise they'll be ignored.
  #
  
  !includedir /etc/mysql/conf.d/
  !includedir /etc/mysql/mysql.conf.d/
  </code></pre>
  <p>Please someone help me out.</p>