我想使用heroku pg:push命令将我本地的postgresql数据库推送到heroku。命令看起来像这样:根据heroku文档: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来重置我的数据库。在那之后,我再次尝试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。我需要你的帮助。谢谢!
发布于 2013-11-30 22:57:24
您是否真的在命令中键入了标记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_[SOME COLOR NAME]条目。确保在命令中使用该标记而不是DATABASE。
由于您在本地数据库上有用户名和密码,因此还需要执行前面提到的关于PGUSER和PGPASSWORD的部分。下面是pg:pull文档中的示例:
$ 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发布于 2014-05-18 23:48:26
我知道这是一个老生常谈的话题,但我也有同样的问题。虽然不是很方便,但我还是通过pg:backups实现了这一点。
这在heroku support site上有很好的细节
首先安装免费的pgbackups插件:
heroku addons:add pgbackups然后使用本地pg_dump实用程序(包含在PostGreSQL发行版中)备份数据库
pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dmp然后将该转储文件放在URL可寻址的地方(例如Dropbox),并运行heroku导入(对于Windows,确保它是双引号):
heroku pg:backups:restore 'https://dropbox.com/dYAKjgzSTNVp4jzE/mydb.dmp' DATABASE_URL发布于 2016-05-02 14:09:58
您需要以下命令
PGUSER=root PGPWD=root heroku pg:push (local database name) DATABASE_URL --app heroku (app name)请确保输入了正确的postgres用户名和密码
https://stackoverflow.com/questions/19490938
复制相似问题