2

When I tried to install PostgreSql 11/12 on my windows machine I was getting the below error :

Error while initializing database cluster

Screenshot of the error

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?

4
  • Read the installation log, maybe it has more details. Commented Apr 8, 2020 at 14:02
  • Yes, I selected a path outside of C:\Program FIles. I do have full privileges for that folder. I have antivirus installed. I will try disabling it and install it again. Commented Apr 8, 2020 at 14:17
  • Can you try to run initdb manually? "c:\Program Files\PostgreSQL\12\bin\initdb" -D C:\pg\data (adjust the path to initdb.exe according to your installation path) Commented Apr 8, 2020 at 14:39
  • @AashmiChaudhary: I have added an answer with a bit more details Commented Apr 9, 2020 at 7:40

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

"c:\Program Files\PostgreSQL\12\bin\initdb" -D C:\pg\data I try to run this and I get that postgre is not on same folder, but it is!!! Any tips on this?
0

The way I fixed this is the folllowing:

  1. Download the Postgres installer for Windows (EDB site)

  2. 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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.