Ruby on rails 如何连接到数字海洋服务器中的远程数据库

Ruby on rails 如何连接到数字海洋服务器中的远程数据库,ruby-on-rails,postgresql,digital-ocean,Ruby On Rails,Postgresql,Digital Ocean,我在windows本地机器上有一个rails应用程序,在digital ocean server[ubuntu服务器]上有一个postgresql远程数据库。如何连接它,我试着这样: database.yml default: &default adapter: postgresql encoding: unicode host: xxx.xxx.xxx.xx username: username password: password schema_search_path: "publ

我在windows本地机器上有一个rails应用程序,在digital ocean server[ubuntu服务器]上有一个postgresql远程数据库。如何连接它,我试着这样:

database.yml

default: &default
adapter: postgresql
encoding: unicode
host: xxx.xxx.xxx.xx
username: username 
password: password
schema_search_path: "public,shared_extensions"

# For details on connection pooling, see Rails configuration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
 <<: *default
 database: database_name
default:&default
适配器:postgresql
编码:unicode
主持人:xxx.xxx.xxx.xx
用户名:username
密码:密码
架构搜索路径:“公共、共享扩展”
#有关连接池的详细信息,请参阅Rails配置指南
# http://guides.rubyonrails.org/configuring.html#database-汇集
游泳池:
发展:

是的,没错。只需确保您的数据库服务器正在运行并接受来自其他系统的连接。。也许这会有帮助。@KrupaSuthar谢谢你。我会检查并更新。@KrupaSuthar我们需要添加主机服务器的密码吗???digital ocean为用户提供的密码droplet@KrupaSuthar我想,我们应该为tcp打开端口5432,我通过运行comman
ufw allow 5432/tcp
从服务器手动打开,感谢您共享的链接。它提供了一些帮助。是的,没错。只需确保您的数据库服务器正在运行并接受来自其他系统的连接。。也许这会有帮助。@KrupaSuthar谢谢你。我会检查并更新。@KrupaSuthar我们需要添加主机服务器的密码吗???digital ocean为用户提供的密码droplet@KrupaSuthar我明白了,我们应该为tcp打开端口5432,我通过运行comman
ufw allow 5432/tcp从服务器手动打开,感谢您共享的链接。它提供了一些帮助。