尝试将Heroku数据库下载到本地:连接到数据库失败

时间:2017-04-12 18:58:27

标签: ruby-on-rails postgresql heroku

我正在关注this文档,尝试将我的Heroku数据库拉到我的localhost。我已成功运行heroku pg:backups:captureheroku pg:backups:download并在我的文件结构中看到latest.dump文件。

但是,当我尝试运行pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump时,我收到以下错误:

pg_restore: connecting to database for restore
pg_restore: [archiver (db)] connection to database "mydb" failed: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?  could not connect to server: Connection refused      
Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

任何人都可以帮我弄清楚如何解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

要在恢复期间创建mydb数据库,您需要--create选项。否则,该命令将根据错误消息查找名为mydb的现有数据库,该数据库似乎不存在。