postgresql Postgres 教程:pg_restore:[archiver] 输入文件似乎不是有效的存档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35246737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:10:07  来源:igfitidea点击:

Postgres Tutorial: pg_restore: [archiver] input file does not appear to be a valid archive

postgresqltarpg-restorepostgresql-9.5

提问by Charlie Weems

I'm working through the Postgres DVD tutorialand am running into issues importing their sample database.

我正在学习Postgres DVD 教程,并且在导入他们的示例数据库时遇到了问题。

Running pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar.gzgives me pg_restore: [archiver] input file does not appear to be a valid archive.

跑步pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar.gz给了我pg_restore: [archiver] input file does not appear to be a valid archive

My process so far has been the following:

到目前为止,我的流程如下:

  1. Download the dvdrental.zipfile
  2. Extract it to a .tar using tar czf dvd-database.tar.gz dvdrental.zip(I've also tried extracting the zip to a folder first with the same result, as well as dropping the .gz)
  3. Running pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.taras stated above.
  1. 下载dvdrental.zip文件
  2. 将其解压缩到 .tar 使用tar czf dvd-database.tar.gz dvdrental.zip(我也试过首先将 zip 解压缩到一个文件夹中,结果相同,以及删除 .gz)
  3. pg_restore -U postgres -d dvdrental ~[filepath]/dvd-database.tar如上所述运行。

I'm currently using Postgres 9.5, which may be causing the issue. Looking for an answer that points out where I'm going wrong in this process or how to update an archive of a Postgres database to 9.5.

我目前正在使用 Postgres 9.5,这可能会导致问题。寻找一个答案,指出我在这个过程中哪里出错了,或者如何将 Postgres 数据库的存档更新到 9.5。

回答by Charlie Weems

Per comments above, the solution was simple.

根据上面的评论,解决方案很简单。

Extracting the dvdrental.zip file to an uncompressed .tar is not necessary as suggested in the tutorial instructions. pg_restorewill workif pointed to the directorywhere the database dump was extracted:

无需按照教程说明中的建议将 dvdrental.zip 文件解压缩为未压缩的 .tar。如果指向提取数据库转储的目录pg_restore将起作用

pg_restore -U <username> -d dvdrental <your/path/to/extracted/dir>/dvdrental

pg_restore -U <username> -d dvdrental <your/path/to/extracted/dir>/dvdrental

回答by Krishnadas PC

After trying for hours which worked for me is the below command. Since PgAdmin 4 it's very hard to work with.

经过几个小时对我有用的是以下命令。由于 PgAdmin 4 很难使用。

/Library/PostgreSQL/10/bin/pg_restore -U postgres -p 5433  -d dvdrental /pg-db/dvdrental/

Just extract the zip into a folder and execute the pg_restorecommand with these options in my case Mac os where /pg-db/dvdrental/is the zip extracted directory.

只需将 zip 解压缩到一个文件夹中,并pg_restore在我的情况下使用这些选项执行命令,在 Mac os 中/pg-db/dvdrental/,zip 解压缩的目录在哪里。