17

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?

RolandoMySQLDBA
  • 171,728
  • 30
  • 293
  • 486
Larry Eitel
  • 271
  • 1
  • 2
  • 4
  • see install log (it should be somewhere on disk, probably in %TEMP%) – filiprem Jan 05 '12 at 22:41
  • Please see pertinent log output. – Larry Eitel Jan 06 '12 at 00:03
  • Does the postgres *Windows* user have **full** read and write privileges on C:\PostgreSQL\data? – a_horse_with_no_name Jan 06 '12 at 08:40
  • Yes, AND per a suggestion elsewhere, I gave Users Modify permissions to that directory. – Larry Eitel Jan 06 '12 at 11:39
  • @LarryEitel: but "*Failed to ensure the data directory is accessible (C:\PostgreSQL\data)*" seems to indicate otherwise. – a_horse_with_no_name Jan 06 '12 at 12:30
  • Indeed. However, I have verified that postgres has Full permissions in PostgreSQL & PostgreSQL/data. I also uninstalled while leaving these DIRs and permissions. Reinstalled FROM user postgres. Same outcome. :( I am thinking to try version 8X. I just need a stable stack for running GeoDjango. – Larry Eitel Jan 06 '12 at 14:57
  • I typically just download the binary and run initdb with a privileged account – swasheck Sep 13 '12 at 14:59
  • IIRC, permissions (and how they work) on the base of the C: drive are slightly different from the permissions given for directories (and elsewhere) in Windows; check the properties for your C: drive and look at how the permissions are set up. You may wish to create the PostgreSQL directory as a sub-directory, using an existing directory that the account already has permissions for. – Avery Payne Sep 13 '12 at 22:46
  • Install log is in Users\\AppData\Local\Temp\install-postgresql.txt. Note that AppData is hidden, but you can just type it into the path textbox at the top of Explorer. – John May 28 '15 at 00:37
  • I had similar trouble installing on a 2012R2 VM. Company policy was to install apps on D:, leaving C: for OS. D: was on a SAN somewhere. Some kind of access control issue seemed to prevent the init process working. I solved it by installing in C:\Postgres. (Note that C:\Program Files\ also has more stringent access controls, and others have reported problems installing it in there.) – John May 28 '15 at 00:41
  • Had this problem on Windows 10. For me the solution was to choose a locale different from [Default Locale] when prompted during install. – Vlad Jan 14 '19 at 00:09
  • I can't answer this question, but I solved this by following [this answer](https://dba.stackexchange.com/a/248584/205787) – Thammarith Apr 05 '20 at 10:45

5 Answers5

21

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
    
Imraan
  • 351
  • 3
  • 7
  • 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. – Larry Eitel Aug 09 '12 at 14:39
  • 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. – Avery Payne Sep 13 '12 at 22:43
  • 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 '12 at 14:47
  • @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) – a_horse_with_no_name Oct 02 '12 at 21:39
  • Keep in mind that, for step 4, `administrators` is locale dependent. For example, in PT-BR it is `administradores`. And, in step 5, `"power users"` is `"usuários avançados"`. – GuiRitter Apr 26 '19 at 19:46
  • 1
    And this procedure didn't fix it for me. I'm still getting the cluster initialization failed message during installation. – GuiRitter Apr 26 '19 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.

Mark
  • 41
  • 1
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! :)

Nav
  • 121
  • 3
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.

NimChimpsky
  • 384
  • 3
  • 10
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.

user37408
  • 11
  • 1