我正在尝试使用RPostgreSQL连接到位于Amazon RDS上的3个不同数据库。我可以连接到其中的2个,但出现1个错误。
我正在Ubuntu 18.04上运行脚本。相同的脚本可以在我办公室的Windows 10计算机上完美运行。
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con1 <- dbConnect(drv,
dbname=dbname1,
host=host1,
port=port-number,
user=user1,
password=password1)
con2 <- dbConnect(drv,
dbname=dbname2,
host=host2,
port=port-number,
user=user2,
password=password2)
con3 <- dbConnect(drv,
dbname=dbname3,
host=host3,
port=port-number,
user=user3,
password=password3)
con1和con3执行完美,但con2给出错误提示
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect user2@host2:5432 on dbname dbname2: server
closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
)