【发布时间】:2019-11-02 21:35:42
【问题描述】:
我目前在 AWS EC2 (Ubuntu) 中运行 PostgreSQL 服务器,并且无法从本地服务器访问它。如何从本地 RStudio 访问远程数据库?
R 中的代码:
library(RPostgreSQL)
library(DBI)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user='postgres', password='password', dbname='dvd', host='ec2-xx-xxx-xxxx-xxxx.ap-northeast-2.compute.amazonaws.com',port=5432)
dbListTables(con)
结果:
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect postgres@ec2-xx-xxx-xxxx-xxxx.ap-northeast-2.compute.amazonaws.com:5432 on dbname "dvd": FATAL: no pg_hba.conf entry for host "130.17.152.1”, user "postgres", database "dvd", SSL off
)
Calls: <Anonymous> ... eval -> dbConnect -> dbConnect -> postgresqlNewConnection
Execution halted
对于 AWS 安全组,我为 PostgreSQL 添加了一个入站,其源设置为端口范围为 5432 的任何位置。
【问题讨论】:
-
您能否提供更多有关您遇到的问题的信息?是超时、连接被拒绝等吗?
-
您正在寻找的答案似乎在这里:dba.stackexchange.com/questions/83984/…
标签: r postgresql amazon-ec2