sachin murali
sachin murali

Reputation: 489

mysql is not working on AWS linux instance?

I have an linux instance on AWS and MySQL database working on it. I was able to connect to the instance via workbench on my local machine. However, I am not able to connect to the database via the node js code. Below is the snippet

var mysql = require('mysql');

const db = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "",
    database:"experience"

  });

  db.connect((err)=>{
      if(err){
          console.log("database error...plzz start ur xammp");  
      }
      else{
          console.log("mysql is up and running smoothy");
      }

  });

  module.exports = db;

Upvotes: 0

Views: 68

Answers (1)

Nirbhay Shah
Nirbhay Shah

Reputation: 319

Can you connect to mysql using the command line in the instance using the command:

mysql -u DBUSER -h DBSERVERNAME_OR_IP -p

Or

mysql -u user_name -h mysql_server_ip_address_here -p db_name_here

Upvotes: 1

Related Questions