amazon rds db error Error: connect ETIMEDOUT

amazon rds db error Error: connect ETIMEDOUT

我正在尝试将 Amazon RDS 数据库连接到我的 nodeJs 应用程序,但出现错误,我的配置是这样的

const connection = mysql.createConnection({
    host: '***********.*************.************.amazonaws.com',
    user: '**********',
    password: '************',
    database: '************',
    port: '3306',
  });
  connection.connect((err) => {
    if (!err) {
      start();
    }
  });

您也可以尝试使用 ssh 并参考 https://www.npmjs.com/package/mysql-ssh 这个库

我通过在 RDS 实例的安全组中添加以下入站规则解决了我的问题:

Type: MySQL/Aurora
Protocol: TCP
Port range: 3306
Source: <Security group of the EC2 instance running Node app> OR <IP address of the machine running Node App>