Dase M
Dase M

Reputation: 123

could not open version file PG_VERSION postgresql pg upgrade

I need some help please, I am upgrading postgresql from v10 to v11 on Windows, but get the following error message: could not open version file: C:/Program Files/PostgresSQL/11/data/PG_VERSION.

Here are the steps taken:

  1. Stopped both PostgresSQL v10 and PostgresSQL v11 services using

    services.msc
    
  2. Set full access control/complete permissions for users for both v10 and v11.

  3. Created 'postgres' user account with full admin rights.
  4. Opened command-line and entered

    RUNAS /USER:postgres "CMD.EXE
    

    prompted to enter password for user postgres user.

  5. New command-line window opens and cd to 'C:\Program Files\PostgreSQL\11'.

  6. Entered the following:
pg_upgrade.exe --old-datadir "C:/Program Files/PostgreSQL/10/data" --new-datadir "C:/Program Files/PostgreSQL/11/data" --old-bindir "C:/Program Files/PostgreSQL/10/bin" --new-bindir "C:/Program Files/PostgreSQL/11/bin" --check

On pressing enter I get the above mentioned error.

I am new to the whole process of using PostgreSQL.

Any thoughts on what is wrong?

Upvotes: 11

Views: 11472

Answers (2)

rhellem
rhellem

Reputation: 869

I had to grant \postgres modify access to both the old and the new datadirectory. That solved the problem for me while upgrading from 9.6 to 10

Upvotes: 0

LarsDK
LarsDK

Reputation: 347

I had the same problem. I solved it by not running a cmd as postgres user. Instead I made a passwsord file and set the env PGPASSFILE accordingly:https://www.postgresql.org/docs/11/libpq-pgpass.html

Apparently when running cmd as postgres user, it was some permissions that prohibited the PG_VERSION to be opened

Upvotes: -1

Related Questions