![](/img/trans.png)
[英]Django 1.8 migrating data from local database to heroku database
[英]How to push local django database into heroku database
我已经使用 postgres 数据库创建了 django 项目我已将我的项目部署到 heroku 服务器,并且还迁移
heroku 运行 python manage.py migrate
我想将我存储的数据库推送到 heroku 数据库,
PGUSER=edpuser PASSWORD=1qazxsw2 heroku pg:push applications postgresql-curly-07168 --app application
但得到
> error shiv@shiv:~/Documents/projects/django_related_project/zoedp$
> heroku pg:push applications postgresql-curly-07168 --app application
> heroku-cli: Pushing applications ---> postgresql-curly-07168 ▸
> Remote database is not empty. Please create a new database or use
> heroku pg:reset
我还运行命令 heroku pg:reset 并再次尝试这次我遇到错误
shiv@shiv:~/Documents/projects/django_related_project/zoedp$ PGUSER=edpuser PASSWORD=1qazxsw2 heroku pg:push applications postgresql-curly-07168 --app application
heroku-cli: Pushing edpapplication ---> postgresql-curly-07168
pg_dump: [archiver (db)] connection to database "application" failed: FATAL: Peer authentication failed for user "edpuser"
pg_restore: [custom archiver] could not read from input file: end of file
▸ pg_dump errored with 1
这是我的setting.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'applications',
'USER': 'edpuser',
'PASSWORD': '1qazxsw2',
'HOST': 'localhost',
'PORT': '5432',
'ATOMIC_REQUESTS': True
}
}
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)
并覆盖 pg_hba.conf 拒绝我。 我该怎么办?
我遇到了这个问题,与postgresql auth 配置有关,而不是与 heroku pg:push命令有关
我会推荐这种方法:
为postgres用户设置密码:基于这个惊人的答案: https : //stackoverflow.com/a/26735105/3172310
此时:您已经为 postgres 用户设置了密码并配置 postgres 在使用 psql 时询问 id,这似乎是 pg 命令。
然后像这样运行命令:
PGUSER=postgres PASSWORD=pg_password heroku pg:push local_db_name DATABASE_URL --app application_name
更换:
应该可以正常工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.