【问题标题】:Restoring from Postgres sql file从 Postgres sql 文件恢复
【发布时间】:2018-11-14 02:53:36
【问题描述】:

我有一个以这种方式创建的 PostgresSQL 数据库的备份:

/usr/bin/pg_dump --no-owner --no-acl > dump.sql

当我尝试在另一台机器上恢复时:

psql db < dump.sql 会引发很多错误:invalid command \N

当我尝试使用pg_restore:

pg_restore dump.sql -d db

不同的错误:pg_restore: [archiver] input file appears to be a text format dump. Please use psql.

根据documentation,这应该不是问题。

有什么方法可以告诉psql \N 字符是空值?

【问题讨论】:

  • 尝试psql -U role -d dbname -f filename.sql删除<
  • @dwir182 与invalid command \N相同的错误
  • 您备份使用pg_dump 似乎很奇怪.. 没有您备份的数据库,甚至没有角色要在数据库中指定架构?
  • 请告诉我们您收到的第一条错误消息。

标签: database postgresql pg-restore


【解决方案1】:

嗨,我是我

确保:

  • 数据库存在
  • 导入用户有权限
  • \N 泛滥之前获取第一个错误
  • psql -d database -f backup.sql -U user 应该可以解决导入问题

还要吃得健康,好好休息。再见

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-20
    • 1970-01-01
    • 1970-01-01
    • 2014-02-19
    相关资源
    最近更新 更多