【问题标题】:error pushing local database into postgresql database for heroku将本地数据库推送到 heroku 的 postgresql 数据库时出错
【发布时间】:2020-11-08 03:54:04
【问题描述】:

我在 SQLite 中有一个本地数据库,我正在尝试将数据库推送到 Heroku。不幸的是,我不断收到以下错误:

heroku pg:push db.sqlite DATABASE_URL --app snaplost
heroku-cli: Pushing db.sqlite ---> postgresql-rigid-38880
pg_dump: error: connection to database "db.sqlite" failed: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
pg_restore: error: could not read from input file: end of file
 ▸    pg_dump errored with 1

我该如何解决这个问题?

【问题讨论】:

  • 您使用什么语言? .你能把db配置文件的代码sn-p放在这里吗?在 heroku 中,默认数据库是 postgresql 。尝试根据postgresql更改db参数。

标签: database postgresql sqlite heroku


【解决方案1】:

heroku pg:push 将本地 PostgreSQL 数据库推送到 Heroku Postgres。您可以在错误消息中看到它正在尝试连接到本地 Postgres 服务器:

could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

您不能以这种方式推送 SQLite 数据库。 PostgreSQL 和 SQLite 是完全不同的产品。即使您将数据库转储为 SQL 语句并在远程上运行它们也可能无法正常工作,因为这些产品并不完全兼容。

在开发和生产中使用相同的数据库服务器总是一个好主意。我建议您创建一个本地 PostgreSQL 数据库并使用您使用的任何工具进行设置。如果您正在使用数据库迁移和支持多个数据库后端的工具,可能很幸运,您会发现只需迁移 Postgres 数据库即可。

拥有本地 Postgres 数据库后,您可以再次尝试使用 heroku pg:push

【讨论】:

    猜你喜欢
    • 2015-10-23
    • 2015-02-25
    • 2013-12-09
    • 2011-03-10
    • 2021-03-04
    • 2020-12-30
    • 2013-04-05
    • 2014-07-20
    • 1970-01-01
    相关资源
    最近更新 更多