15

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?

  • see install log (it should be somewhere on disk, probably in %TEMP%) – filiprem Jan 5 '12 at 22:41
  • Please see pertinent log output. – Larry Eitel Jan 6 '12 at 0:03
  • Does the postgres Windows user have full read and write privileges on C:\PostgreSQL\data? – a_horse_with_no_name Jan 6 '12 at 8:40
  • Yes, AND per a suggestion elsewhere, I gave Users Modify permissions to that directory. – Larry Eitel Jan 6 '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 6 '12 at 12:30
17

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
    
  • 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 9 '12 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 '12 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. – Avery Payne Sep 13 '12 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) – a_horse_with_no_name Oct 2 '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

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! :)

1

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

0

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.