我正在尝试使用以下命令将数据库转储到本地系统中:
pg_restore --host=localhost --port=5432 --dbname=dev_db --no-owner --no-privileges db_dump_new.backup
但我收到错误:
pg_restore: [archiver] input file is too short (read 0, expected 5)
我究竟做错了什么?
我正在尝试使用以下命令将数据库转储到本地系统中:
pg_restore --host=localhost --port=5432 --dbname=dev_db --no-owner --no-privileges db_dump_new.backup
但我收到错误:
pg_restore: [archiver] input file is too short (read 0, expected 5)
我究竟做错了什么?
如果您使用 docker 并从本地机器重定向转储文件,请不要忘记-i
. 这不起作用:
docker exec <container> pg_restore -U "$USER" < ./localfile.dump;
确保 docker 容器可以通过-i
选项看到标准!这应该有效:
docker exec -i <container> pg_restore -U "$USER" < ./localfile.dump;
我遇到了同样的错误。就我而言,我只是忽略了在命令末尾指定备份文件。
In my case I used docker
$ docker exec a5f7b094c523 pg_restore -d my_new_db < "./2256.dump"
pg_restore: [archiver] input file is too short (read 0, expected 5)
And the issue was that "./2256.dump" is not a binary file but a plain sql text dump.
To check that just do
$ head ~/2256.dump
--
-- PostgreSQL database dump
--
-- Dumped from database version 10.8 (Ubuntu 10.8-0ubuntu0.18.04.1)
-- Dumped by pg_dump version 10.8 (Ubuntu 10.8-0ubuntu0.18.04.1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
And to import sql dump fo
$ pv ~/2256.dump |docker-compose -f docker-compose.dev.yml -f docker-compose.override.yml -T db psql "fight-round3"
使用此命令,它将完美地使用 pgadmin 4 中 Postgres 13 中的 sql 文件恢复 db 文件
C:\Program Files\PostgreSQL\13\bin>psql -U user_name db_name< D:\dbfile\sql_file.sql