[英]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.