I'm trying to install PostgreSQL 9.0.1 on Windows Server 2008, but every time, there will be such error message
"Problem running post-install step. Installation may not complete correctly. Failed to start the database server"
in the installation log, it is due to a failure in initdb.exe
, error is
"The program postgres is needed by initdb, but was not found in the same directory as D:\PostgreSQL\9.0\bin\initdb.exe, Check your installation."
I searched such error in internet and tried the solution in this page "Installing PostgreSQL on Windows Server 2008", but no help.
After reading code of initdb
, I know it is caused by the window api CreateProcess in the function pipe_read_line. the calling of CreateProcess returned -5 (access denied). it is because initdb was executed in a subprocess invoked in the functiion CreateRestrictedProcess.
I know it is due to privilege setting, I ran gpedit.msc to add users group (even everyone) into almost all privilege policy, but the error was still there.
I also assigned full control rights of the install target folder to everyone, no help!
I also tried postgresql 9.6.2, the error was still there :-)
from the code, I know if there is the environment variable PG_RESTRICT_EXEC
with value 1, initdb will not executed in a restricted process. so before run initdb.exe, I set an environment PG_RESTRICT_EXEC=1 in command prompt, then run initdb.exe. this time such error was gone!!
So I wonder how to change the os settings to allow the installation running without error!