postgresql AWS RDS:如何连接到实例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20207006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AWS RDS: How to Connect to Instance
提问by David Williams
I just set up an Amazon RDS instance. 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. On the Instance page, I have
我刚刚设置了一个 Amazon RDS 实例。我有一个单独的应用程序服务器,我想弄清楚如何从我的 EC2 应用程序服务器连接到 RDS 实例。在实例页面上,我有
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 地址。
回答by slayedbylucifer
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. the port has to be specified using --port
option and not hostname:port
您port
在命令中指定了错误的信息。必须使用--port
选项指定端口而不是hostname:port
回答by Nicholas Porter
This syntax worked for me in the psql command line:
此语法在 psql 命令行中对我有用:
\connect dbname username hostname port#
\connect dbname 用户名主机名端口#
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 访问