Reputation: 33
When I tried to install PostgreSql 11/12 on my windows machine I was getting the below error :
Error while initializing database cluster
Below are the details - Port No - 5432 Installation Location - I have tried installing it in C:/ProgramFiles and also directly in C drive Password - test123 I am running the installer as administrator I have access to Temp directory as well. I have tried moving data folder outside of the main folder. Below are the solutions I have tried -
Below is the error in log file:
Error running cscript //NoLogo "C:\pg/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\u6105742\AppData\Local\Temp/postgresql_installer_2714a75545" "C:\pg" "C:\pg\data" 5432 "DEFAULT" 0: Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
The database cluster initialisation failed.
Executing icacls "C:\Users\u6105742\AppData\Local\Temp/postgresql_installer_e172900ce0" /inheritance:r Script exit code: 0
Could someone please help me in this issue?
Upvotes: 2
Views: 9574
Reputation: 11
The way I fixed this is the folllowing:
Download the Postgres installer for Windows (EDB site)
Open a Powershell with admin rights and execute the following:
.\postgresql-<version>-windows-x64.exe --install_runtimes 0 --unattendedmodeui minimal --mode unattended --superpassword "<set your superuser password here>" --servicename "postgreSQL"
Replace the < version > with the current version you are trying to install and the superuser password of your choice.
It will install everything and create a service called postgreSQL.
Upvotes: 0
Reputation:
On Windows I typically don't use the installer any more as its attempt to set privileges correctly is laudable but seems to create more problems than it solves (especially with computers that a part of a Windows domain seem to suffer from that).
Manually running initdb
seems to be more robust, but you will have to fix the permissions on the data directory yourself, e.g.:
"c:\Program Files\PostgreSQL\12\bin\initdb" -D C:\pg\data
If you want a Windows service, this can be done using pg_ctl:
"c:\Program Files\PostgreSQL\12\bin\pg_ctl" register -N postgresql-12 -D C:\pg\data
The Windows service will run using the Windows "Local System" account which sometimes is seen as dangerous - but isn't as dangerous as described in that SO answer, because Postgres will drop all elevated privileges when it starts the service.
Upvotes: 4