Yasiru Ayeshmantha
Yasiru Ayeshmantha

Reputation: 101

how to connect nodejs sequelize aws rds mysql database and ec2 instances

I'm trying to connect my EC2 instance and AWS RDS MySQL database. Ii returns the database not found an error.

How can I fix git fix?

RDS database successfully connect with my MySQL workbench

const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(__filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};

let sequelize;
if (config.use_env_variable) {
  sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
  sequelize = new Sequelize('*db name*', '***username***', '****pwd*****', {
    host: '*********.us-east-2.rds.amazonaws.com',
    port: 3306
    logging: console.log,
    maxConcurrentQueries: 100,
    dialect: 'mysql',
    dialectOptions: {
        ssl:'Amazon RDS'
    },
    pool: { maxConnections: 5, maxIdleTime: 30},
    language: 'en'
});
}

db.Sequelize = Sequelize;
db.sequelize = sequelize;

module.exports = db;

I'm using

Screenshot of the error.

screenshot

Upvotes: 2

Views: 2422

Answers (1)

Yasen
Yasen

Reputation: 4504

As per screenshot, you are trying to connect to the DB using it's DB name.

But there is a little confusion between AWS RDS DB Instance name and MySQL default DB name is mysql.

So, I'd suggest to use mysql instead of AWS-tvrs as DB name.

Upvotes: 1

Related Questions