could not open version file PG_VERSION postgresql pg upgrade
Asked Answered
G

2

11

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?

Glaser answered 15/11, 2019 at 20:44 Comment(5)
1. How are you upgrading PostgreSQL? What steps are you following? 2. What command generates that error? 3. What do the logs say?Ezzo
Using pg_upgrade from v11 and ran the following pg_upgrade --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 from C:\Program Files\PostgreSQL\11 from the cliGlaser
Storing the data directory into c:\Program File is a really bad idea. Regular users are not allowed to write there (for good reasons). It's a really, really bad choice of the EnterpriseDB installer to suggest that directory. %ProgramData% is much better place to store thatChicky
Yes, but it's a local machine I use for development, only I have use this machineGlaser
I had this error because I had a copy paste error, and instead of passing a data dir I was passing a bin dir. Doesn't look like your problem, but maybe the data dir in you old distribution was renamed? Did you end up finding a solution?Farant
R
0

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

Radiophone answered 16/11, 2021 at 13:51 Comment(0)
B
-1

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

Burdick answered 21/8, 2020 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.