HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Pg install: "The database cluster initialisation failed"

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
installthedatabasefailedinitialisationcluster

Problem

(Note: This question has been compeltely rewritten from its original form, so it reflects the actual problem and will help others find a solution to the same issue).

I still haven't been able to successfully install PostgreSQL on my Windows 7 Ultimate x64 computer. See this prior question for some history.

I did a fresh instillation of 9.2 and the only error I got was this one:

It reads:


"Problem running post-install step. Installation may not complete
correctly. The database cluster initialisation failed".

This occurs even after I do a complete manual uninstall of PostgreSQL and pgAmdin-III:

  • Ran the PostgreSQL uninstaller, which failed with the error Error stopping service postgresql-x64-9.2.



  • Removed all the PostgreSQL-related registry entries for PostgreSQL under HKEY_LOCAL_MACHINE\SOFTWARE and HKEY_CURRENT_USER\SOFTWARE



  • Removed the postgres user account using net user postgres /delete in an Administrator command prompt (shift-right clicked on "Command Prompt" in start menu, chose "Run as administrator")



  • Removed the postgres user profile



  • Deleted the C:\Program Files\PostgreSQL\ directory, including the data directory within %appdata%



  • Removed some PgAdmin-III registry entries that pointed to PostgreSQL



  • Removed the service account for postgres from services.msc



When I reboot and try the installer again it fails with the same message.

The install-postgresql.log file from %TEMP% contains:

Executing cscript //NoLogo "C:\Program Files\PostgreSQL\9.2/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Program Files\PostgreSQL\9.2" "C:\Program Files\PostgreSQL\9.2\data" 5432 "DEFAULT"
Script exit code: 1


then another error a bit later:

creating template1 database in C:/Program Files/PostgreSQL/9.2/data/base/1 ... initdb: could not execute command ""C:/Program Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error


See full installer log file download here.

Solution

It appears that the root cause of this issue may have been that @Celeritas's computer had an incorrect value for the COMSPEC environment variable. It had a trailing semicolon, so instead of the normal:

C:\Windows\system32\cmd.exe


it was:

C:\Windows\system32\cmd.exe;


This one-character difference is enough. The above isn't a valid command prompt path, so popen() calls were failing. Unfortunately, instead of something useful like:

'"C:\Windows\system32\cmd.exe;"' is not recognized as an internal or external command, operable program or batch file


it instead reports the delightfully useful error No error:

initdb: could not execute command ""C:/Program Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error


See related:

  • http://forums.enterprisedb.com/posts/list/2125.page



  • http://postgresql.1045698.n5.nabble.com/initdb-failure-td2083455.html



I've reported this to the installer team and written a wiki entry to describe it. See blog post.

The issue was eventually resolved by:

  • Editing the COMSPEC environment variable



  • Uninstalling PostgreSQL



  • Rebooting



  • Reinstalling PostgreSQL



though there was a lot more before that which shouldn't actually be necessary to resolve this, including doing a total manual clean uninstall of PostgreSQL by hand.

Now I just want to find the people who wrote the program that modified this environment variable.

Code Snippets

C:\Windows\system32\cmd.exe
C:\Windows\system32\cmd.exe;
'"C:\Windows\system32\cmd.exe;"' is not recognized as an internal or external command, operable program or batch file
initdb: could not execute command ""C:/Program Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error

Context

StackExchange Database Administrators Q#28836, answer score: 6

Revisions (0)

No revisions yet.