加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

推数据库到heroku:如何使用heroku pg:push

发布时间:2020-12-12 08:31:18 所属栏目:MsSql教程 来源:网络整理
导读:我想把本地的 postgresql数据库推送到heroku,使用heroku pg:push命令.命令如下:heroku pg:push mylocaldb DATABASE –app sushi根据英雄文件: https://devcenter.heroku.com/articles/heroku-postgresql. 这是我的本地数据库信息: Name: mysitedbUser: b
我想把本地的 postgresql数据库推送到heroku,使用heroku pg:push命令.命令如下:heroku pg:push mylocaldb DATABASE –app sushi根据英雄文件: https://devcenter.heroku.com/articles/heroku-postgresql.

这是我的本地数据库信息:

Name: mysitedb
User: bill
Password: bill

我的机器中的DATABASE_URL环境变量设置为:postgres:// bill:bill @ localhost / mysitedb.

我的应用程序的名字是secure-gorge-4090.我尝试了heroku pg:push mysitedb DATABASE –app secure-gorge-4090.产量为:

!    Remote database is not empty.
 !    Please create a new database,or use `heroku pg:reset`

我很惊讶,我没有把我的数据库.但是我仍然运行heroku pg:reset DATABASE来重置我的DATABASE.之后,我再次尝试了heroku pg:push mysitedb DATABASE –app secure-gorge-4090,但是输出仍然是一样的.

我试过heroku pg:push postgres:// bill:bill @ localhost:8000 / mysitedb DATABASE –app secure-gorge-4090.产量为:

!    LOCAL_SOURCE_DATABASE is not a valid database name

我不知道如何使用这个命令将我的本地数据库移动到heroku.我需要你的帮助.谢谢!

解决方法

您是否真的在命令中键入令牌DATABASE,或者是您用于此问题的占位符?从 docs you linked to:
Like pull but in reverse,pg:push will push data from a local database into 
a remote Heroku Postgres database. The command looks like this:

$heroku pg:push mylocaldb HEROKU_POSTGRESQL_MAGENTA --app sushi

This command will take the local database “mylocaldb” and push it to the 
database at DATABASE_URL on the app “sushi”. In order to prevent accidental 
data overwrites and loss,the remote database must be empty. You will be 
prompted to pg:reset an already a remote database that is not empty.

Usage of the PGUSER and PGPASSWORD for your local database is also supported
for pg:push,just like for the pg:pull commands.

当你做heroku config -a secure-gorge-4090时,你应该看到一个条目为HEROKU_POSTGRESQL_ [一些颜色名称].确保您在命令中使用任何令牌,而不是DATABASE.

由于您在本地数据库中有用户名和密码,您还需要提及有关PGUSER和PGPASSWORD的部分.以下是pg:pull docs的示例:

$PGUSER=postgres PGPASSWORD=password heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

所以你应该这样做:

$PGUSER=bill PGPASSWORD=bill heroku pg:push mysitedb HEROKU_POSTGRESQL_[SOME COLOR] -a secure-gorge-4090

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读