Problems Installing PostgreSQL 9.2

2020-02-09 05:20发布

问题:

I've been trying to install the 64bit version of PostgreSQL 9.2 for Windows on my machine (Windows 7 64bit) and get this error:

The environment variable COMPSPEC does not seem to point to the cmd.exe or there is a trailing semi colon present.

I've installed it as Administrator.

I disabled the antivirus (Microsoft Security Essentials) and the firewall.

Running:

"%COMSPEC%" /C "echo test ok"

returned test ok

I've checked my System Environment Variables for trailing semi colon and I couldn't find any.

I then installed the 32bit version and managed to get to the end of the install with a different error message stating: Problem running post-install step. Installation may not complete correctly Error reading the C:\Program Files (x86)\PostgreSQL\9.2\data\postgresql.conf but there is no postgresql.conf file in that directory. It did install the application and when I try to connect the server with the red X on it it says fail at the bottom and it won't connect after I type in my password.

How can I connect to this server connection?

回答1:

ComSpec is a generic error message for any installation failure.

Identifying the problem

  1. Navigate to below path c:\Users\XXXXXX\AppData\Local\Temp
  2. Open 'bitrock_installer_XXXX.log'
  3. Check, if you are getting below error:

Script stderr: '"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command, operable program or batch file.

Error running

C:\Users\XXXXX\AppData\Local\Temp/postgresql_installer_47b21c4ea1/temp_check_comspec.bat :
'"C:\Users\XXXXX\AppData\Local\Temp\POSTGR~1\TEMP_C~1.BAT"' is not recognized as an internal or external command,

operable program or batch file.

This is a problem with '8.3 file names and directories' (e.g. '\Postgres Install' -> '\POSTGR~1') Microsoft article on disabling 8.3 file names and directories: https://support.microsoft.com/en-gb/kb/121007

Solution:

  1. Open command prompt in admin mode
  2. Execute following command to change the format based on your drive or all drives

    Sample commands:

    fsutil 8dot3name set 1"      - disable 8dot3 name creation on all volumes
    fsutil 8dot3name set C: 1"   - disable 8dot3 name creation on c:
    
  3. Execute the installation as a user having admin privileges

  4. After install, consider resetting the 8dot3name setting to default (2) to avoid unintended consequences

Hope it solves the problem!



回答2:

Very easy fix:

  1. Just open Advanced System Settings in Control Panel and create a new System Variable( in the System Variable instead of User Variable section).

  2. In the variable name, enter ComSpec and then in the variable value , enter C:\Windows\system32\cmd.exe.

Alternative fix:

If you have already the ComSpec variable in the System Variable section, remove the ;at the end of it this should fix it.



回答3:

It's not COMPSPEC it's just COMSPEC. Please show the output of:

echo %COMSPEC%

Note that COMSPEC could be set to something different in the Administrator account you're running the installer as. I'm not sure how to find that out, but it might appear in the PostgreSQL installer log, so please upload that and link to it in your post. See Reporting an installation error for info on where to get the installer log.

See the PostgreSQL for Windows FAQ entry Check the COMSPEC environment variable.

Here's a report I made suggesting that the installer should test for this explicitly and here's my blog post on the topic.



回答4:

I got the same problem, and i found in the log:

Script stderr: 'C:\Users\S300' is not recognized as an internal or external command, operable program or batch file.

Error running C:\Users\S300 (i5)\AppData\Local\Temp/postgresql_installer_56caeadbd6/temp_check_comspec.bat : 'C:\Users\S300' is not recognized as an internal or external command, operable program or batch file.

I change in User Variables TEMP to D:\TEMP and TMP to D:\TEMP. And Solved My Problem.



回答5:

I had a similar problem. After installation, the data folder contained no postgres.conf file. It only contained a single folder named "pg_log". I described the solution that I used here: Postgres Installation Error reading file postgresql.conf

Basically, it would be helpful to check if the user has full permissions for the postgres folder, and run "init_db" and "pg_ctl start" commands again. If the path contains a space character, try using a relative path for the pg_ctl data folder argument.



回答6:

I'm running Windows Server 2003 R2, and I have been unable to resolve this problem with the installer, so I resorted to using the binary PostgreSQL package. Hopefully this will be an alternative for others who do not want to perform an OS reinstall.

First, some background (hopefully useful to the developers)

It started out with the postgres service failing to start (the server had been running reliably for over a year). I assumed it was a corrupted PostgreSQL installation, so I uninstalled and attempted to reinstall. I encountered the following error:

There has been an error.
The environment variable COMSPEC does not seem to point to the cmd.exe or there is a trailing semicolon present.
Please fix this variable and restart installation.

However, the COMSPEC variable is set properly, verified with:

echo %COMSPEC%
C:\WINDOWS\system32\cmd.exe

and:

"%COMSPEC%" /C "echo test ok"
test ok

Since this is Windows Server 2003, there is no UCA wrapper around the Administrator account, so that is not causing the problem.

Manual Installation

NET USER postgres /ADD

C:\pgsql\bin\initdb.exe -U postgres -A password -E utf8 -W -D C:\pgsql\data

runas /user:postgres "C:\pgsql\bin\pg_ctl -D C:/pgsql/data -l C:/pgsql/logfile.txt start"


回答7:

just do it run as administrator and change the environment system variable like create a new variable 'ComSpec' and value type 'C:\Windows\system32\cmd.exe'.



回答8:

In my case , the Installer was in %USERPROFILE%\DownloadsP{ Windows download folder}, I moved the installer to desktop and ran again. weird it worked lol.



回答9:

If the installer exe is on a network share that mapped drive might actually not be accessible to the installer as it runs as administrator. This can often happen in some virtual machine arrangements such as running windows in a parallels VM. Copy the installer to a local drive first and you won't have a problem.