简体   繁体   English

找不到 NodeJS AWS RDS 连接数据库错误

[英]NodeJS AWS RDS Connection Database Not Found Error

I am brand new to MySQL and AWS in general so excuse me if this is a silly question but here goes: I am trying to create a connection between my nodejs application and my MYSQL database hosted on AWS.我是 MySQL 和 AWS 的新手,所以如果这是一个愚蠢的问题,请原谅我,但这里是:我正在尝试在我的 nodejs 应用程序和我在 AWS 上托管的 MYSQL 数据库之间建立连接。 I have this so far到目前为止我有这个

var mysql = require('mysql');

var connection = mysql.createConnection({
  host: "AWS RDS Endpoint",
  user: "username",
  password: "password",
  database: "DB Instance Name on AWS Console"
});

connection.connect(function(err) {
  if (err) {
    console.error('Database connection failed: ' + err.stack);
    return;
  }

  console.log('Connected to database.');
});

connection.end();

When I try running the code I get back "Unknown database 'DB Instance Name on AWS Console'" with the database name being, obviously the db instance name that appears on the AWS console.当我尝试运行代码时,我返回“Unknown database 'DB Instance Name on AWS Console'”,数据库名称显然是出现在 AWS 控制台上的数据库实例名称。 The password and username I know are correct but I'm not sure about the host or database parameters.我知道的密码和用户名是正确的,但我不确定主机或数据库参数。 Can anyone give me some insight into, if I am doing this correctly?如果我这样做正确,谁能给我一些见解?

Last attribute database, should be DB name attribute from configuration tab, which is default database we choose when creating RDS最后一个属性数据库,应该是configuration选项卡中的DB name属性,这是我们在创建RDS时选择的默认数据库

OR you can remove database attribute completely if you are using an admin credentials.或者,如果您使用的是管理员凭据,则可以完全删除database属性。

var connection = mysql.createConnection({
  host: "my-mysql-instance.acdefghij.us-east-1.rds.amazonaws.com",
  user: "username",
  password: "password"
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用nodejs和RDS数据库出现mysql连接超时是什么原因 - What is the reason for mysql connection timeout using nodejs and RDS database PostgreSQL 连接尝试超时错误的 AWS RDS - AWS RDS for PostgreSQL Connection attempt timed out error AWS RDS 的 Terraform Postgresql 提供程序错误:“拨号 tcp 127.0.0.1:5432:连接:连接被拒绝” - Terraform Postgresql provider error for AWS RDS: "dial tcp 127.0.0.1:5432: connect: connection refused" AWS Elastic Beanstalkl Nodejs React部署报错babel: command not found - AWS Elastic Beanstalkl Nodejs React Deployment Error babel: command not found 如何复制 AWS RDS 数据库,而不是整个实例 - How to copy an AWS RDS database, NOT the entire instance 将 csv 文件从 s3 导入 rds PostgreSQL 数据库 > 错误:模式“aws_commons 不存在 - Importing a csv file from s3 into rds PostgreSQL Database > Error: schema "aws_commons does not exist InvalidParameterCombination错误部署RDS数据库集群 - InvalidParameterCombination error deploying RDS database cluster 如何将 MySql 数据库从 AWS RDS 连接到 datastudio - How to connect MySql Database from AWS RDS to datastudio AWS Glue 从 VPC 中的 RDS 数据库读取 - AWS Glue read from RDS database that's in VPC 数据库连接挂在 AWS Lambda 上 - Database connection hanging on AWS Lambda
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM