我正在关注this文档,尝试将我的Heroku数据库拉到我的localhost。我已成功运行heroku pg:backups:capture
和heroku 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?
任何人都可以帮我弄清楚如何解决这个问题吗?
答案 0 :(得分:2)
要在恢复期间创建mydb
数据库,您需要--create
选项。否则,该命令将根据错误消息查找名为mydb
的现有数据库,该数据库似乎不存在。