1

I'm trying to migrate a PostgreSQL 9.5 database to a larger disk E on a Windows 2008 Server. After stopping the service I initially tried copying the the data folder to the new disk and then changed the PostgreSQL Service's executable path using

sc config postgresql-x64-9.5 binPath= "\"C:\Program Files\PostgreSQL\9.5\bin\pg_ctl.exe\" runservice -N \"postgresql-x64-9.5\" -D \"E:\pg_db\data\" -w"

I changed the permissions on the data folder to include "Network Services" by right-clicking on the folder and going Properties. Under the Security Tab click "Edit..." and then "Add...". Type "Network Service" and then click "Check Names" and then OK.

But when I hit Start in Services, the following error message appears under the Windows Event Viewer:

FATAL: data directory "E:/pg_db/data" does not exist.

I even tried creating a new data directory from the administrator cmd prompt using instructions here but eventually got the same error.

I see one of the answers to the "Similar Questions" as I'm writing this is "It is easier if you reinstall Postgre and select data folder during install." That can't be the best we can do.

3
  • Have you seen this link? stackoverflow.com/questions/22596301/…
    – alzee
    Aug 2, 2016 at 20:16
  • @user3137702, just tried that. I get EDT FATAL: data directory "E:/pg_db/data" does not exist again
    – raphael
    Aug 2, 2016 at 20:41
  • Also (since that didn't work), it's better to use sc config ... because that sets the right user for the postgres Service
    – raphael
    Aug 2, 2016 at 20:52

1 Answer 1

0

Found the problem while scanning through the Running & Installing PostgreSQL On Native Windows Wiki

The PostgreSQL service account needs read permissions on all directories leading up to the service directory. It needs write permissions only on the data directory.

I had set the write permission on the data directory for Network Service but not the read permission on the directories above it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .