ruby-on-rails pgsync无法连接到RDS上的Amazon PostgreSQL数据库

c0vxltue  于 2022-12-30  发布在  Ruby
关注(0)|答案(1)|浏览(136)

我正在尝试使用pgsync gem将数据从本地dev数据库同步到Amazon RDS上运行的测试DB。
我的.pgsync.yml页面很简单:

from: postgres://localhost:5432/imports_development?sslmode=require
to: [See attempts below]
exclude:
  - [A few tables]

我尝试了很多方法,但都不起作用。以下是所有方法和我收到的错误信息:

to: postgres://awsuser:mypassword@imports-test.abcdefg.us-east-1.rds.amazonaws.com/postgres?sslca=config/rds-combined-ca-bundle.pem
  => invalid URI query parameter: "sslca"

to: postgres://awsuser:mypassword@imports-test.abcdefg.us-east-1.rds.amazonaws.com
  => connection to server at "52.4.150.10", port 5432 failed: FATAL:  database "awsuser" does not exist

to: $(heroku config:get DATABASE_URL)
  => invalid URI parameter: "sslca"

to: imports-test.abcdefg.us-east-1.rds.amazonaws.com
  => connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  database "imports-test.abcdefg.us-east-1.rds.amazonaws.com" does not exist

以下是database.yml用于RDS数据库的凭据:

rds_db_name: postgres
rds_username: awsuser
rds_password: mypassword
rds_hostname: imports-test.abcdefg.us-east-1.rds.amazonaws.com
rds_port: 5432

我可以用rails console连接到两个数据库,所以只需要正确地使用上面的语句就可以了。

rlcwz9us

rlcwz9us1#

你试过postgres://awsuser:mypassword@imports-test.abcdefg.us-east-1.rds.amazonaws.com/postgres吗?第二次尝试似乎可以,但是根据错误,没有包括DB名称。
URI的格式大致如下:

postgres://{USER}:{PASS}@{HOSTNAME}/{DBNAME}

?sslca=123和其他选项AFTER ?(查询字符串)表示选项。并非所有客户端都支持此处的所有选项。

相关问题