简体   繁体   English

AWS RDS:如何连接到实例

[英]AWS RDS: How to Connect to Instance

I just set up an Amazon RDS instance. 我刚刚设置了一个Amazon RDS实例。 I have a separate application server and I am trying to figure out how to connect to the RDS instance from my EC2 application server. 我有一个单独的应用程序服务器,我试图找出如何从我的EC2应用程序服务器连接到RDS实例。 On the Instance page, I have 在Instance页面上,我有

enbdpoint: mycompany.czdv3mj7ps25.us-west-2.rds.amazonaws.com:5432

I tried to login into to psql using that address but I got 我尝试使用该地址登录到psql,但我得到了

$ psql -h mycompany.czdv3mj7ps25.us-west-2.rds.amazonaws.com:5432 -U myuser -d mydb
psql: could not translate host name "mycompany.czdv3mj7ps25.us-west-2.rds.amazonaws.com:5432" to address: Name or service not known

How do I connect to the instances database? 如何连接到实例数据库? I don't see any other ip addresses in the RDS console. 我没有在RDS控制台中看到任何其他IP地址。

You have wrong syntax. 你的语法错了。 The correct syntax is: 正确的语法是:

$ psql --host mycompany.czdv3mj7ps25.us-west-2.rds.amazonaws.com --port 5432 --username myuser --dbname mydb

You have specified port information wrong in you command. 您在命令中指定了错误的port信息。 the port has to be specified using --port option and not hostname:port 必须使用--port选项而不是hostname:port指定hostname:port

This syntax worked for me in the psql command line: 这个语法在psql命令行中对我有用:

\\connect dbname username hostname port# \\ connect dbname username hostname port#

If the information is correct it will take a couple seconds to process then it will ask for your password 如果信息正确,则需要几秒钟的时间来处理,然后它会询问您的密码

Also make sure the security group for your instance, the outbound/inbound is setup to allow access from your IP 还要确保实例的安全组,出站/入站设置为允许从IP进行访问

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM