嗨,我已经在使用nodejs和loopback的示例应用程序上创建了。什么时候 我尝试使用“db”内存工作。当我添加lb datasource时 抛出mysql错误。请帮我解决一下。
{
"db": {
"name": "db",
"connector": "memory"
},
"mysql": {
"host": "ec2-52-35-183-50.us-west-2.compute.amazonaws.com",
"port": "3307",
"url": "",
"database": "medola",
"password":"xxyyxx@123",
"name": "mysql",
"user": "root",
"connector": "mysql"
}
}
Connection fails: Error: connect ECONNREFUSED 172.31.24.147:3307 It will be retried for the next request. events.js:160
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 172.31.24.147:3307
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
--------------------
at Protocol._enqueue (/home/ec2-user/medola/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/home/ec2-user/medola/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at PoolConnection.connect (/home/ec2-user/medola/node_modules/mysql/lib/Connection.js:130:18)
at Pool.getConnection (/home/ec2-user/medola/node_modules/mysql/lib/Pool.js:48:16)
at MySQL.connect (/home/ec2-user/medola/node_modules/loopback-connector-mysql/lib/mysql.js:89:17)
at Object.initializeDataSource [as initialize] (/home/ec2-user/medola/node_modules/loopback-connector-mysql/lib/mysql.js:43:28)
at DataSource.setup (/home/ec2-user/medola/node_modules/loopback-datasource-juggler/lib/datasource.js:352:19)
at new DataSource (/home/ec2-user/medola/node_modules/loopback-datasource-juggler/lib/datasource.js:121:8)
at Registry.createDataSource (/home/ec2-user/medola/node_modules/loopback/lib/registry.js:355:12)
at dataSourcesFromConfig (/home/ec2-user/medola/node_modules/loopback/lib/application.js:440:19)
at EventEmitter.app.dataSource (/home/ec2-user/medola/node_modules/loopback/lib/application.js:235:14)
at /home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:190:9
at /home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:281:5
at Array.forEach (native)
at forEachKeyedObject (/home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:280:20)
at setupDataSources (/home/ec2-user/medola/node_modules/loopback-boot/lib/executor.js:180:3)
答案 0 :(得分:0)
请确保您在IAM角色中设置了正确的权限。 http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAM.html