18

Both C:\PostgreSQL and C:\PostgreSQL\data have postgres user with full access and admin rights.

I ran postgresql-9.1.2-1-windows.exe from postgres user as admin. Target C:\PostgreSQL

Every way I try, I get "The database cluster initialization failed."

Questions

  • Is it OK to run everything w/o being a Windows Service?
  • Is there a work-around to install as Windows Service?

I am trying to setup PostGIS to work with GeoDjango.

I was able to manually install PostGIS. New to PostgreSQL and I am having a crisis of confidence over all of this. Coming from MySQL to PostgreSQL for the first time.


Pertinent log output from C:\Users\Larry\AppData\Local\Temp\install-postgresql.log:

WScript.Network initialized...
Called IsVistaOrNewer()...
    'winmgmts' object initialized...
    Version:6.1
    MajorVersion:6
Ensuring we can read the path C: (using icacls) to Larry:
    Executing batch file 'radA3CF7.bat'...
    Output file does not exists...
Called IsVistaOrNewer()...
    'winmgmts' object initialized...
    Version:6.1
    MajorVersion:6
Ensuring we can read the path C:\PostgreSQL (using icacls) to Larry:
    Executing batch file 'radA3CF7.bat'...
    Output file does not exists...
Called IsVistaOrNewer()...
    'winmgmts' object initialized...
    Version:6.1
    MajorVersion:6
Ensuring we can read the path C:\PostgreSQL\data (using icacls) to Larry:
    Executing batch file 'radA3CF7.bat'...
    Output file does not exists...
Called IsVistaOrNewer()...
    'winmgmts' object initialized...
    Version:6.1
    MajorVersion:6
Ensuring we can write to the data directory (using icacls) to  Larry:
    Executing batch file 'radA3CF7.bat'...
    Output file does not exists...
Failed to ensure the data directory is accessible (C:\PostgreSQL\data)
    Executing batch file 'radA3CF7.bat'...
    Output file does not exists...
Called Die(Failed to initialise the database cluster with initdb)...
Failed to initialise the database cluster with initdb

Suggestions?

12
  • see install log (it should be somewhere on disk, probably in %TEMP%)
    – filiprem
    Jan 5, 2012 at 22:41
  • Please see pertinent log output. Jan 6, 2012 at 0:03
  • Does the postgres Windows user have full read and write privileges on C:\PostgreSQL\data?
    – user1822
    Jan 6, 2012 at 8:40
  • Yes, AND per a suggestion elsewhere, I gave Users Modify permissions to that directory. Jan 6, 2012 at 11:39
  • @LarryEitel: but "Failed to ensure the data directory is accessible (C:\PostgreSQL\data)" seems to indicate otherwise.
    – user1822
    Jan 6, 2012 at 12:30

5 Answers 5

22

I had the same issue installing 9.1.4 on Windows 7. I managed to find a solution online that worked.

The steps I followed are:

  1. Uninstall PostgreSQL
  2. Delete the postgres user if it still exists.

    net user postgres /delete
    
  3. Create the postgres user with a password you can remember

    net user /add postgres <password>
    
  4. Add the postgres user to the Administrators group

    net localgroup administrators postgres /add
    
  5. Add the postgres user to the Power Users group

    net localgroup "power users" postgres /add
    
  6. Run a command window as the postgres user

    runas /user:postgres cmd.exe
    
  7. Run the install file from within the command window.

    C:\Download\postgresql-9.1.4-1-windows.exe
    

    This should run the installation successfully.

  8. Remove the postgres user from the Administrators group.

    net localgroup administrators postgres /delete
    
6
  • Thank you for the feedback. Unfortunately, I have since shifted this project to Mongodb. I am not in a position at the moment to confirm your suggestion. Aug 9, 2012 at 14:39
  • I want to confirm that the solution worked for me. Setup: Postgres 9.1 64 bit and PostGIS 2.0.1 x64
    – Chris
    Sep 13, 2012 at 14:47
  • 1
    This is a well-known issue with re-installation of PostgreSQL that is running as a service, and I have personally run into the situation that this answer addresses. The installer leaves behind an account upon removal or upgrade, but the 2nd installation does not factor this in; the resulting credential disparity between installations creates havoc. The most-common answer is the one Imraan gives; un-install, remove the offending account, then re-install. Sep 13, 2012 at 22:43
  • @AveryPayne: alternatively: remember the correct password for the postgres service account. I have installed Postgres a lot on systems where it was already installed and never had a problem with an existing service account. The wording in the installer could have been improved though (with 9.2 Postgres doesn't use an explicit account any longer btw)
    – user1822
    Oct 2, 2012 at 21:39
  • 2
    And this procedure didn't fix it for me. I'm still getting the cluster initialization failed message during installation.
    – GuiRitter
    Apr 26, 2019 at 19:55
4

I had the same error message when trying to install 9.2.4. My issue was because even though the Win2k8 server had %SYSTEMROOT%\system32 as part of the path, no programs could "see" anything in C:\Windows\system32. The installer heavily uses icacls.exe during the init routine. Since my path was screwed up, the installer bombed out.

Once I explicitly added C:\Windows\system32 to the SYSTEM's Path environment variable and re-ran the installer as an admin, everything worked fine.

2

In my case (as I saw from the postgresql.log file in %temp% folder of Windows), it was because the installer was unable to find doskey.exe even though the path to c:\windows\system32 folder was given in the environment variable path of windows.
So I opened up a command prompt, typed set PATH=%PATH%;c:\windows\system32 and ran the installer from the command prompt itself. It worked! :)

2

None of the above worked for me. I had no use postgres.

So I deleted/uninstalled everything. Ran cmd as administrator.

Then ran the installer from command line (as admin) and selected a completely new location for the data directory.

I have now succesfully reinstalled postgres, after half a day of jiggery pokery.

1
  • i did that and still didn't work for me.
    – EKanadily
    Jan 31, 2020 at 21:45
1

This problem has to do with write permission on folder. Create the folder / data into PostgreSQL \ 9.2 for example, and give full permission to the user. Try reinstalling again.

Not the answer you're looking for? Browse other questions tagged or ask your own question.