使用pg_upgrade从PostgreSQL 10升级到12时出错

问题描述

我安装了Postgresql 10,并且刚刚安装了Postgresql 12(在Windows上)。我正在尝试使用pg_upgrade数据库上进行迁移。但是,我收到一个烦人的错误

我运行的命令如下:

$ pg_upgrade.exe -b 'C:\Program Files\Postgresql\10\bin\' -B 'C:\Program Files\Postgresql\12\bin\
' -d 'C:\Program Files\Postgresql\10\data\' -D 'C:\Program Files\Postgresql\12\data\'

但是,我收到错误消息:

You must identify the directory where the new cluster binaries reside.
Please use the -B command-line option or the PGBINNEW environment variable.
Failure,exiting

...尽管很清楚。

有人看过吗?

解决方法

this page的步骤“ 9)运行pg_upgrade中,从“对于Windows用户..用户”部分:

对于Windows用户,您必须登录到管理帐户,然后以postgres用户身份启动Shell并设置正确的路径:

RUNAS /USER:postgres "CMD.EXE"
SET PATH=%PATH%;C:\Program Files\PostgreSQL\12\bin;

,然后使用带引号的目录运行pg_upgrade,例如:

pg_upgrade.exe
   --old-datadir "C:/Program Files/PostgreSQL/9.6/data"
   --new-datadir "C:/Program Files/PostgreSQL/12/data"
   --old-bindir "C:/Program Files/PostgreSQL/9.6/bin"
   --new-bindir "C:/Program Files/PostgreSQL/12/bin"