如何将 .sql 文件导入 Heroku postgres 数据库? [英] How can I import a .sql file into my Heroku postgres database?

查看:37
本文介绍了如何将 .sql 文件导入 Heroku postgres 数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个来自另一个数据库的备份 sql 文件,我想将其导入 Heroku 的 postgres 数据库.你是怎么做到的?

I have a backup sql file from another database that I want to import into Heroku's postgres database. How do you do that?

推荐答案

这就是你的做法:

heroku pg:psql --app YOUR_APP_NAME_HERE < updates.sql

如果您想将生产恢复到暂存状态(假设两者都是 heroku postgres 数据库):

And if you want to restore your production into staging (assuming both are heroku postgres DBs):

heroku pgbackups:restore YOUR_STAGING_DATABASE_NAME `heroku pgbackups:url --app YOUR_PRODUCTION_APP_NAME` --app YOUR_STAGING_APP_NAME --confirm YOUR_STAGING_APP_NAME

确保保留 heroku pgbackups:url --app YOUR_PRODUCTION_APP_NAME 周围的特殊单引号.

Make sure to preserve the special single quotes around heroku pgbackups:url --app YOUR_PRODUCTION_APP_NAME.

Heroku 最近更新了他们的工具带,因此旧的命令不再有效(请参阅 此链接 了解更多信息).下面是恢复命令的新版本.

Heroku has recently updated their toolbelt so the old commands are no longer valid (see this link for more info). Below is the new version of the restore command.

heroku pg:backups restore 
  `heroku pg:backups public-url -a YOUR_PRODUCTION_APP_NAME` 
  YOUR_STAGING_DATABASE_NAME 
  --app YOUR_STAGING_APP_NAME 
  --confirm YOUR_STAGING_APP_NAME

这篇关于如何将 .sql 文件导入 Heroku postgres 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆