postgresql - 在 MacOS 下使用 MacPorts 安装 PostgreSQL 12 / PostGIS 3.0 时,如何使用 postgis_restore.pl 脚本?
问题描述
我全新安装了 PostgreSQL 12 / PostGIS 3.0,在 MacOS (Mojave) 下使用 MacPorts 完成,我尝试使用传统脚本 postis_restore.pl 恢复启用 PostGIS 的数据库。
我首先创建了一个启用了 PostGIS 3.0 的空数据库。我的数据库转储来自带有 PostGIS 2.5 的 PosgtresSQL 9.4。它是使用 -Fc 格式完成的。
我尝试:
perl /opt/local/share/postgresql12/contrib/postgis-3.0/postgis_restore.pl /Users/me/Documents/db/dump_file.dump | psql -h localhost -U postgres target_db 2>errors.txt
我得到以下答案:
Converting /Users/me/Documents/db/dump_file.dump to ASCII on stdout...
Reading list of functions to ignore...
Writing manifest of things to read from dump file...
Writing ASCII to stdout...
ALTER TABLE
ALTER TABLE
pg_restore: error: one of -d/--dbname and -f/--file must be specified
Done.
SELECT 8500
DELETE 8500
UPDATE 0
INSERT 0 8500
DROP TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
怎么解决 :
pg_restore: error: one of -d/--dbname and -f/--file must be specified
谢谢
解决方案
在 PostgreSQL 12 中,pg_restore 的行为被更改为要求 -f 或 -d。以前,如果两者都没有指定,那么它会将其输出流式传输到 stdout,现在通过指定-f -
. 之所以更改,是因为许多人对旧行为感到困惑(尽管更改本身也令人困惑)。
显然 postgis_restore.pl 从未更新以反映此更改。您应该能够找到调用 pg_restore 的位置并添加-f -
到它。尽管鉴于此脚本显然从未经过测试,但我会谨慎使用它而无需进一步审查。
推荐阅读
- apexcharts - 组合图表顶点图表中的自定义位置
- javascript - 在 React 中使用 useContext 和 useReducer 创建新的键值对
- flutter - Flutter 从 firebase_admob 切换到 google_mobile_ads
- java - 从 Apache Kerby TGTTicket 检索字符串令牌
- java - g.drawString() 上的 Java“换行文本”+“自动字体大小”
- javascript - React Apex Chart 中的折线图在自定义工具提示中返回 [object Object]
- python - 在数据框中查找唯一值并从另一个唯一数据框中相乘 - Python
- c++ - C++20 std::ranges:范围适配器跳过每第 n 个元素
- r - 如何为 Y 有 2 个系列的多列绘制新图表
- python - 设置标签的背景透明