Postgresql failed to install correcty - postgresql

I have been trying to install PostgreSQL 9.2 for the last couple of days. I guess I tried everything that I could find online but the service still will not start. I am currently running Windows 7 SP1. I used to have PostgreSQL 8.3 installed and working fine but a couple of weeks ago I decided to uninstall it. I thoroughly uninstalled it (delete the postgres user and the data file) and now every time I try to install any version I get this non-fatal error at the end of the setup when the loading of the database modules takes place.
I managed to see that the postgresql service does not start or as windows puts it starts then stops.
This is the relevant part of the log file of the installation:
Successfully processed 771 files; Failed processing 0 files
initcluster.vbs ran to completion
Script stderr:
Configuring database server startup...
Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL\9.2\installer\server\startupcfg.vbs" 9.2 "NT AUTHORITY\NetworkService" "****" "C:\Program Files (x86)\PostgreSQL\9.2" "C:\Program Files (x86)\PostgreSQL\9.2\data" "postgresql-9.2"
Script exit code: 0
Script output:
startupcfg.vbs ran to completion
Script stderr:
Creating menu shortcuts...
Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL\9.2\installer\server\createshortcuts.vbs" 9.2 "postgres" 5432 "PostgreSQL 9.2 (x86)" "C:\Program Files (x86)\PostgreSQL\9.2" "C:\Program Files (x86)\PostgreSQL\9.2\data" "postgresql-9.2"
Script exit code: 0
Script output:
Start FixupFile(C:\Program Files (x86)\PostgreSQL\9.2\scripts\serverctl.vbs)...
Opening file for reading...
Closing file (reading)...
Replacing placeholders...
Opening file for writing...
Closing file...
End FixupFile()...
Start FixupFile(C:\Program Files (x86)\PostgreSQL\9.2\scripts\runpsql.bat)...
Opening file for reading...
Closing file (reading)...
Replacing placeholders...
Opening file for writing...
Closing file...
End FixupFile()...
createshortcuts.vbs ran to completion
Script stderr:
Starting the database server...
Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL\9.2\installer\server\startserver.vbs" postgresql-9.2
Script exit code: 0
Script output:
Starting postgresql-9.2
Service postgresql-9.2 started successfully
startserver.vbs ran to completion
Script stderr:
Loading additional SQL modules...
Executing cscript //NoLogo "C:\Program Files (x86)\PostgreSQL\9.2\installer\server\loadmodules.vbs" "postgres" "****" "C:\Program Files (x86)\PostgreSQL\9.2" "C:\Program Files (x86)\PostgreSQL\9.2\data" 5432
Script exit code: 2
Script output:
Installing the adminpack module in the postgres database...
Executing 'C:\Users\George\AppData\Local\Temp\radA5996.bat'...
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Failed to install the 'adminpack' module in the 'postgres' database
loadmodules.vbs ran to completion
Script stderr:
Program ended with an error exit code
Error running cscript //NoLogo "C:\Program Files (x86)\PostgreSQL\9.2\installer\server\loadmodules.vbs" "postgres" "****" "C:\Program Files (x86)\PostgreSQL\9.2" "C:\Program Files (x86)\PostgreSQL\9.2\data" 5432 : Program ended with an error exit code
[10:34:28] Write the data directory to the ini file...
[10:34:28] Write the port number, service ID, locale and superuser to the ini file...
[10:34:28] Write ServiceID(postgresql-9.2) to registry/ini...
[10:34:28] Write Superuser to ini file and windows registry...
[10:34:28] Write Service Account to ini file and windows registry...
[10:34:28] Write the server description to the ini file...
[10:34:28] Write the server branding to the ini file...
[10:34:28] Write the 'whether stack-builder is disabled or not' to the ini file...
[10:34:29] Finished running post-installation/upgrade tasks.
Creating Uninstaller
Creating uninstaller 25%
Creating uninstaller 50%
Creating uninstaller 75%
Creating uninstaller 100%
Installation completed

I had the same problem. At one point it needs to get a package via internet connection. This is not right because the install package s/b able to install without a connection but that's how it is. Your firewall is blocking the install. Here's what you need to do:
Shut Down Windows Firewall (Control Panel\All Control Panel Items\Windows Firewall\Customize Settings)
If you use this great program shut down Firewall Control (Exit from task bar or Use Task Mgr to kill UI & Service - 2 items)
For downloading Selected Packages:
Shut Down Key Protection Services:
Shut Down Base Filtering (Leaves you unprotected! - Dependencies will.restart when BFE is restarted)
Base Filtering Engine
IKE and AuthIP IPsec Keying Modules
IPsec Policy Agent
ICS
...
Don't forget to restart all protections.

I faced similar issues of Pg 9.2.4 installer on Win7 x64. It turned out that
'adminpack' module did not load due to stopped postgres service. It starts and then
terminates almost immediately. You may check this running Pg service manually to see if it
can load. If it cant this may be from missing config files from "data" directory. initdb
command cant create valid cluster and copy corresponding *.conf files. I tried to dig into
details and the installer has complicated checks of user permissions which could fail in your (and my) case.
Just try installing Pg from zip binaries. It took only the following commands (less than
20 minutes). Original article.
1) Create "postgres" windows user (with no admin rights) and granted it full privileges on
your Pg folder and "data" folder. To do this from command line run "cmd" as administrator (press Ctrl-Shift-Enter instead of Enter to run "cmd") and issue: "net user postgres
/add". Then right click on your Pg folder (and "data" folder if it is outside) and grant all permissions to "postgres".
2) Install Microsoft Visual C++ 20xx Redistributable Package which comes with one click Pg
installer (vcredist_x64.exe from Users\"your user"\AppData\Local\Temp\postgresql_installer_**** - folder created by one click Pg installer on first run).
3) Unzip Pg binaries to your Pg folder and "cmd" as administrator to its bin directory.
4) Run to init cluster: initdb -U postgres -A password -E utf8 -W -D "path to your Pg folder"\data
5) Run to install windows service: pg_ctl register -N "postgresql" -U ".\postgres" -D "path to your Pg folder/data" -w
6) Open windows services list and open "postgresql" service properties. Then set password for windows user postgres there. Try starting your new Pg service. If it starts then everything should be ok.
7) Open bin\pgAdmin3, connect to local server and open postgres database and its metadata. You should see a complaint about missing admin services and a propose to correct this. Just press Ok - 'adminpack' should be installed.

Install postgres only from windows account written in english. For example installation from user "Аня" always fail.

Solution is to shutdown the windows firewall before installing. After the installation you can enable the windows firewall.

Try installing outside of "C:\Program Files" which has special permissions on Windows.
We had similar issues and simply by installing into C:\Postres92 everything works right out of the box.

I had the same problem, caused by restricted access rights in the Program Files directory, due to the fact that the data directory was C:\Program Files (x86)\PostgreSQL\9.2\data
Changing the data directory to C:\ProgramData\PostgreSQL\9.2\data resolved the problem.

Related

initdb.exe failed suddenly (Windows)

My application bundles PostgreSQL 9.5.0 and runs initdb.exe manually. It works fine in the most clients.
This A client also installed my application successfully before, but after rebooting their Windows (2008), they got below error. They intentionally just ran "initdb.exe' without any options.
c:\Users\Administrator> "C:\Program Files (x86)\myapp\pgsql\bin\initdb.exe"
The program "postgres" is needed by initdb but was not found in the same directory as "C:\Program Files (x86)\myapp\pgsql\bin\initdb.exe".
Check your installation.
My installer (inno setup) runs below one as well to grant privileges.
(%1 points installation directory).
icacls %1 /grant Everyone:(OI)(CI)F
Someone says that I should try with a non-privileged user as following but I have to reproduce this issue in my local env, and I don't have any issue with Admin or other non-privileged user.
runas /user:username "initdb -D ..."
Can you guide me how I can resolve this issue?

Unable to Install Postgresql on Windows 10

I'm trying to install postgreSQL on my windows 10 computer for the first time. I got two errors at the end of the installation
1) a non-fatal error occured during cluster initialisation. please check the installation log in C:\users\abc\AppData\Local\Temp for details
2) problem running post-install step. Installation may not complete correctly.Failed to start the database-server.
I also tried a number of other (but very dated) solutions to similar problems users experienced such as moving my data directory outside of the Postgres directory entirely. Most of these solutions date back and don't seem to work anymore.
The one that seemed closest to working is [PostgreSQL Database Cluster Initialisation Failed Solution][1]
However, I can't find "postgres" as a user. I get an error saying: "An object named "postgres" cannot be found. Check the selected object types and location for accuracy and ensure that you typed the object name correctly, or remove this object from the selection."
Does anybody have any updated solutions/tips for this?
Please see the logs: I have added some more logs below this.
> Log started 09/08/2017 at 15:35:34
Preferred installation mode : qt
Trying to init installer in mode qt
Mode qt successfully initialized
Executing C:\Users\skum\AppData\Local\Temp/postgresql_installer_c42ee2159f/temp_check_comspec.bat
Script exit code: 0
Script output:
"test ok"
Script stderr:
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-9.6 Data Directory. Setting variable iDataDirectory to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-9.6 Service ID. Setting variable iServiceName to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-9.6 Service Account. Setting variable iServiceAccount to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-9.6 Super User. Setting variable iSuperuser to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-9.6 Branding. Setting variable iBranding to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-x64-9.6 DisableStackBuilder. Setting variable iDisableStackBuilder to empty value
[15:35:38] Existing base directory: C:\Users\skum\postgres_inst
[15:35:38] Existing data directory:
[15:35:38] Using branding: PostgreSQL 9.6
[15:35:38] Using Super User: postgres and Service Account: NT AUTHORITY\NetworkService
[15:35:38] Using Service Name: postgresql-x64-9.6
Executing cscript //NoLogo "C:\Users\skum\AppData\Local\Temp\postgresql_installer_c42ee2159f\prerun_checks.vbs"
Script exit code: 0
Script output:
The scripting host appears to be functional.
Script stderr:
Executing C:\Users\skum\AppData\Local\Temp\postgresql_installer_c42ee2159f\vcredist_x64.exe /passive /norestart
Script exit code: 0
Script output:
Script stderr:
Executing C:\Users\skum\AppData\Local\Temp\postgresql_installer_c42ee2159f\vcredist_x86.exe /passive /norestart
Script exit code: 0
Script output:
Script stderr:
Executing C:\Users\skum\AppData\Local\Temp\postgresql_installer_c42ee2159f\getlocales.exe
Script exit code: 0
Logs Part 1:
Failed to ensure the data directory is accessible (C:\Users\skum\postgresqlData)
Executing batch file 'radB66AD.bat'...
The files belonging to this database system will be owned by user "skum".
This user must also own the server process.
The database cluster will be initialized with locale "English_United States.1252".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory C:/Users/skum/postgresqlData ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... windows
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
Success. You can now start the database server using:
"C:\Users\skum\postgres_inst\bin\pg_ctl" -D "C:\Users\skum\postgresqlData" -l logfile start
Reading: C:\Users\skum\postgresqlData\postgresql.conf exists...
Writing: C:\Users\skum\postgresqlData\postgresql.conf exists...
Called AclCheck(C:\Users\skum\postgresqlData)
Called IsVistaOrNewer()...
'winmgmts' object initialized...
Version:10.
MajorVersion:10
Executing icacls to ensure the NT AUTHORITY\NetworkService account can read the path C:\Users\skum\postgresqlData
Executing batch file 'radB66AD.bat'...
'icacls' is not recognized as an internal or external command,
operable program or batch file.
Called IsVistaOrNewer()...
'winmgmts' object initialized...
Version:10.
MajorVersion:10
Granting service account access to the data directory (using icacls) to NT AUTHORITY\NetworkService:
Executing batch file 'radB66AD.bat'...
'icacls' is not recognized as an internal or external command,
operable program or batch file.
Failed to grant service account access to the data directory (C:\Users\skum\postgresqlData)
initcluster.vbs ran to completion
Script stderr:
Program ended with an error exit code
Error running cscript //NoLogo "C:\Users\skum\postgres_inst/installer/server/initcluster.vbs" "NT AUTHORITY\NetworkService" "postgres" "****" "C:\Users\skum\postgres_inst" "C:\Users\skum\postgresqlData" 5432 "DEFAULT" 0: Program ended with an error exit code
Configuring database server startup...
Executing cscript //NoLogo "C:\Users\skum\postgres_inst\installer\server\startupcfg.vbs" 9.6 "NT AUTHORITY\NetworkService" "****" "C:\Users\skum\postgres_inst" "C:\Users\skum\postgresqlData" "postgresql-x64-9.6"
Script exit code: 0
Script output:
startupcfg.vbs ran to completion
Script stderr:
Creating menu shortcuts...
Executing cscript //NoLogo "C:\Users\skum\postgres_inst\installer\server\createshortcuts.vbs" 9.6 "postgres" 5432 "PostgreSQL 9.6" "C:\Users\skum\postgres_inst" "C:\Users\skum\postgresqlData" "postgresql-x64-9.6"
Script exit code: 0
Script output:
Start FixupFile(C:\Users\skum\postgres_inst\scripts\serverctl.vbs)...
Opening file for reading...
Closing file (reading)...
Replacing placeholders...
Opening file for writing...
Closing file...
End FixupFile()...
Start FixupFile(C:\Users\skum\postgres_inst\scripts\runpsql.bat)...
Opening file for reading...
Closing file (reading)...
Replacing placeholders...
Opening file for writing...
Closing file...
End FixupFile()...
createshortcuts.vbs ran to completion
Script stderr:
Starting the database server...
Executing cscript //NoLogo "C:\Users\skum\postgres_inst\installer\server\startserver.vbs" postgresql-x64-9.6
Script exit code: 1
Script output:
Starting postgresql-x64-9.6
Failed to start the database server (2)
Script stderr:
Program ended with an error exit code
Error running cscript //NoLogo "C:\Users\skum\postgres_inst\installer\server\startserver.vbs" postgresql-x64-9.6: Program ended with an error exit code
Problem running post-install step. Installation may not complete correctly
Failed to start the database server.
Creating Uninstaller
Creating uninstaller 25%
Creating uninstaller 50%
Creating uninstaller 75%
Creating uninstaller 100%
Installation completed
Log finished 09/08/2017 at 15:41:35

How can I start PostgreSQL on Windows?

I have installed Postgresql on my Windows 10 PC. I have used the pgAdmin II tool to create a database called company, and now I want to start the database server running. I cannot figure out how to do this.
I have run the start command on the postgres command line, and nothing seems to happen.
What I doing is:
postgres=# pg_ctl start
postgres=# pg_ctl status
postgres=# pg_ctl restart
postgres=# pg_ctl start company
postgres=# pg_ctl status
.....-> I am seeing nothing returned.
Go inside bin folder in C drive where Postgres is installed.
run following command in git bash or Command prompt:
pg_ctl.exe restart -D "<path upto data>"
Ex:
pg_ctl.exe restart -D "C:\Program Files\PostgreSQL\9.6\data"
Another way:
type "services.msc" in run popup(windows + R).
This will show all services running
Select Postgres service from list and click on start/stop/restart.
Thanks
pg_ctl is a command line (Windows) program not a SQL statement. You need to do that from a cmd.exe. Or use net start postgresql-9.5
If you have installed Postgres through the installer, you should start the Windows service instead of running pg_ctl manually, e.g. using:
net start postgresql-9.5
Note that the name of the service might be different in your installation. Another option is to start the service through the Windows control panel
I have used the pgAdmin II tool to create a database called company
Which means that Postgres is already running, so I don't understand why you think you need to do that again. Especially because the installer typically sets the service to start automatically when Windows is started.
The reason you are not seeing any result is that psql requires every SQL command to be terminated with ; in your case it's simply waiting for you to finish the statement.
See here for more details: In psql, why do some commands have no effect?
If you have installed postgres via the Windows installer you can start it in Services like so:
After a lot of search and tests i found the solution :
if you are in windows :
1 - first you must found the PG databases directory
execute the command as sql command in pgAdmin query tools
$ show data_directory;
result :
------------------------
- D:/PG_DATA/data -
------------------------
2 - go to the bin directory of postgres in my case it's located "c:/programms/postgresSql/bin"
and open a command prompt (CMD) and execute this command :
pg_ctl -D "D:\PSG_SQL\data" restart
This should do it.
The simplest way to start/stop/restart the installed PostgreSQL Server on your Windows device is as follows:
Start -> net start postgresql-x64-14
Stop -> net stop postgresql-x64-14
Restart -> net stop postgresql-x64-14 && net start postgresql-x64-14
The version number must be changed to take into account the installed version of your PostgreSQL Server.
For windows the following command worked well for me
pg_ctl.exe restart -D "<path_to_data>"
Eg: pg_ctl.exe restart -D "D:\Program Files\PostgreSQL\13\data"
If you are getting an error "psql.exe' is not recognized as an internal or external command,... "
There can be :
Causes
System is unable to find the psql.exe tool, because the path to this tool is not specified in the system environment variable PATH
or
- PostgreSQL Database client not installed on your PC
Since you have already installed PostgreSQL the latter can not be the issue(assuming everything is installed as expected)
In order to fix the first one "please specify the full path to the bin directory in the PostgreSQL installation folder, where this tool resides."
For example
Path: "C:\Program Files\PostgreSQL\10\bin"
I found using
net start postgres_service_name
the only reliable way to operate Postgres on Windows
first find your binaries file where it is saved.
get the path in terminal mine is
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries
(1)\pgsql\bin
then find your local user data path, it is in mostly
C:\usr\local\pgsql\data
now all we have to hit following command in the binary terminal path:
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries (1)\pgsql\bin>pg_ctl -D "C:\usr\local\pgsql\data" start
all done!
autovaccum launcher started! cheers!
Remove Postmaster file in "C:\Program Files\PostgreSQL\9.6\data"
and restart the PostgreSQL services
There are different way to open PostgreSql database .
1> One of them is by going windows and select pgAdmin4 or pgAdmin3 depends to version you use and entering password you can access you database .
2> Another one is by terminal :
To able to select from terminal you have to add the path of your installed postgresql by going enviroment variables . To do that got to installed postgresql file and select the path of bin and add to enviroment variable of window setting .
after that you can type in terminal : psql -U postgres -h localhost
Hit enter and it ask you password . After giving password you can create database and tables and can access it .
I was try to solve the problem with Windows Terminal and I've cannot to solve it. Use Windows R + cmd (if you are using Windows) for it work!
The easiest way to enable pg_ctl command is to go to your PostgreSQL directory ~\PostgreSQL\version\bin\ and execute the pg_ctl.exe. Afterwards the pg_ctl commands will be available.

PostgreSQL installation - error loading modules

I haven't been able to re-install PostgreSQL + PostGIS properly on our virtual server.
Installing PostgreSQL the following error occurs about the end of the process:
"A non-fatal error occurred whilst loading database modules. Please check the installation log in C:...\Temp for details."
Here is what the log says:
Loading additional SQL modules...
Executing cscript //NoLogo "C:\Programme\PostgreSQL\9.0\installer\server\loadmodules.vbs" "postgres" "****" "C:\Programme\PostgreSQL\9.0" "C:\Programme\PostgreSQL\9.0\data" 5432
Script exit code: 2
Script output:
Installing the adminpack module in the postgres database...
Executing 'C:\DOKUME~1\Kiesow\LOKALE~1\Temp\rad3C00F.bat'...
Couldn't find the output file...
Failed to install the 'adminpack' module in the 'postgres' database
loadmodules.vbs ran to completion
Script stderr:
Program ended with an error exit code
Error running cscript //NoLogo "C:\Programme\PostgreSQL\9.0\installer\server\loadmodules.vbs" "postgres" "****" "C:\Programme\PostgreSQL\9.0" "C:\Programme\PostgreSQL\9.0\data" 5432 : Program ended with an error exit code
Afterwards installation completes, I can start pgAdmin, log in and create new databases. Everything looks fine until I try to add PostGIS, using the stack builder wizard. Again the installation is almost finished, when:
"Database creation failed."
"Would you like to view the error log " "create_templatepostgis_db_error.txt'?"
This error log doesn't exist. I might ignore the error and create the template db manually, which works. But I cannot use types like 'geometry', so I think, PostGIS is not yet usable.
Maybe anyone of you has got an idea of what I could have done wrong? Any hints? Can anybody help me to interpret the error log?
I use Windows XP, PostgreSQL 9.0 32bit (same with 8.4), PostGIS 1.5.
Postgres 8.3 + PostGIS was installed on this system earlier, but I uninstalled, deleted the data directory and let the installation wizard create a new posgres windows user.
Did a few reboots, too.
And I did choose a locale instead of [Default locale] at Postgres installation.
This is another part of the log I am suspicios of. It is right in the beginning. Maybe this helps:
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Data Directory. Setting variable iDataDirectory to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Base Directory. Setting variable iBaseDirectory to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Service ID. Setting variable iServiceName to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Service Account. Setting variable iServiceAccount to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Super User. Setting variable iSuperuser to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Branding. Setting variable iBranding to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Version. Setting variable brandingVer to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 Shortcuts. Setting variable iShortcut to empty value
Could not find registry key HKEY_LOCAL_MACHINE\SOFTWARE\PostgreSQL\Installations\postgresql-9.0 DisableStackBuilder. Setting variable iDisableStackBuilder to empty value
[15:44:31] Existing base directory:
[15:44:31] Existing data directory:
[15:44:31] Using branding: PostgreSQL 9.0
[15:44:31] Using Super User: postgres and Service Account: postgres
[15:44:31] Using Service Name: postgresql-9.0
Executing cscript //NoLogo "C:\Dokumente und Einstellungen\Kiesow\Lokale Einstellungen\Temp\prerun_checks.vbs"
Script exit code: 0
Script output:
The scripting host appears to be functional.
Script stderr:
Executing cscript //NoLogo "C:\Dokumente und Einstellungen\Kiesow\Lokale Einstellungen\Temp\postgresql_installer\installruntimes.vbs" "C:\Dokumente und Einstellungen\Kiesow\Lokale Einstellungen\Temp\postgresql_installer\vcredist_x86.exe"
Script exit code: 3010
Script output:
Executing the runtime installer: C:\Dokumente und Einstellungen\Kiesow\Lokale Einstellungen\Temp\postgresql_installer\vcredist_x86.exe
The runtime package exited with error code: 3010
From a command prompt, run this single command:
C:\Programme\PostgreSQL\9.0\bin\psql.exe -p 5432 -U postgres -W -f C:\Programme\PostgreSQL\9.0\share\contrib\adminpack.sql postgres
Its output may be more informative. Running the above is all the .vbs is doing, incidentally.
The reason for prompting this error message was due to because of localhost is pointing to some other machine.
disable firewall and antivirus and try installing it again.

Unable to run PostgreSQL as Windows service

I had this in my Windows services:
C:/Program Files/PostgreSQL/8.4/bin/pg_ctl.exe runservice -N "postgresql-8.4" -D "D:/PostgreSQL/8.4/data" -w
It never finishes executing. But if I did this on the dos shell:
C:/Program Files/PostgreSQL/8.4/bin/pg_ctl.exe start -N "postgresql-8.4" -D "D:/PostgreSQL/8.4/data" -w
Notice that I only changed the "runservice" to "start" and it works just fine.
Any idea?
The command runservice can only be executed by the service manager
in order to fix my localhost windows 7 to start postgres as a service
i used the following command to start the data
pg_ctl -D "C:\Program Files\PostgreSQL\9.1\data" start
Then checked the status for errors
pg_ctl -D "C:\Program Files\PostgreSQL\9.1\data" status
if you get error 1063 , its more than likely permissions, i executed the following command
cacls "C:\Program Files\PostgreSQL\9.1\data" /E /T /C /G postgres:F
then reran the start/status, it showed everything fine, but still service manager would not start the service
So, in Services->postgresql->options->logon i set the log on as the Local system account instead of the postgres user, and voila it worked
this happened to me because i set my data directory to be somewhere the postgres windows user account didn't have access to.
I had this problem in Windows after a system crash. Running the first command showed invalid data in C:\Program Files\PostgreSQL\9.1\data\postmaster.pid. Deleting that file did the trick. Reference.
I faced the same issue after moving manually the database data files (PG_DATA directory) without recreating all the necessary permissions.
Here is how I solved my issue:
1. Check permissions on old PG_DATA directory:
cacls "c:\path\to\old\pgdata\dir"
2. Check permissions on new PG_DATA directory:
cacls "d:\path\to\NEW\pgdata\dir"
3. Compare outputs from 1. and 2.
Find the differences between users and/or permissions then synchronize them.
Nota: I found it easier to use explorer for the synchronization step rather than using cacls directly from the command line.
If you changed pg_hba.conf , maybe you missed somewhere in file. For example there must be CIDR after IP in that file. It must be like 192.168.1.100/32
If you forgot to put 32, then server doesnt restart.
Investigation of startup logs could be a clue. For the case problem is in the pg_hba.conf you could see something like this:
2018-11-13 00:39:34.841 PST [8284] FATAL: could not load pg_hba.conf
2018-11-13 00:39:34.842 PST [8284] LOG: database system is shut down
You need to check your logfiles and the windows eventlog for some hint of what the problem is. If there is nothing at all there, you need to break out something like Process Monitor and get a stacktrace of where it's hung.
I have had this issue in the past, and it was that the installer did not set up the permissions correctly for the user that the service was to run as.
I've also ran into this problem with postgresql throwing and error after trying to initialize the database cluster. After analyzing the log files and running command line scripts for 4 hours I've got the solution to anyone running into this problem for Windows Versions.
This is not a detailed description as to why its happening. I've installed odoo 10, 11, 12 and 13 numerous times on countless client servers and windows systems and this is the first time I've ever ran into this problem. I cant say if its because I have MS VS Enterprise installed and Android Studio on this machine or what. But Below is the easy answer on how to fix it and initialize the cluster and create the database files in the data folder.
Open the data folder for postgresql. - For Odoo installs it will normally be "C:\Program Files (x86)\Odoo 13.0\PostgreSQL" Unless you chose another location when installing.
Remove any or all files from this folder - If not you will get an error when running initdb.exe
Right click the data folder and open up the properties for it. Click on the Security tab and then click the advanced button on the bottom.
You need to change the owner of this folder to openpgsvc. Click Change and type in openpgsvc and click ok. Once done click the check box below saying that you want this change to affect containers with this container as well.
Then on the Permissions tab click the add button on the bottom. You need to add openpgsvc as a user and give this user full rights. Click apply and and ok to close out of all the folder properties.
Now you need to open cmd.exe - Once open we are going to call initdb.exe and pass some values to it as well.
First run chdir and change the working directory to the location of initdb.exe. For me, running odoo 13 on a windows 10 machine the location is this..
"C:\Program Files (x86)\Odoo 13.0\PostgreSQL\bin"
There is one variable that need to be passed as well to make this work here is the list. NEEDS TO BE INCLUDED IN THE CALL TO initdb.exe
Postgres Data Dir: "C:\Program Files (x86)\Odoo 13.0\PostgreSQL\data"
The End Result with the parameter would look like this for my installation:
"C:\Program Files (x86)\Odoo 13.0\PostgreSQL\bin\initdb.exe" -D "C:\Program Files (x86)\Odoo 13.0\PostgreSQL\data"
Hit Enter and let it rip. The output of this command should look like this below.
Cmd.exe running initdb.exe script
Make sure there is no buggy empty file Program at C:\ like C:\Program
In this case, explorer will warn whenever you log on into Windows.
File Name Warning
-----------------
There is a file or folder on your computer called "C:\Program" which
could cause certain applications to not function correctly. Renaming it
to "C:\Program1" would solve this problem. Would you like to rename
it now?
Installing PostgreSQL 10 On Windows 7 (yes the clock is ticking...). I first tried the latest version 11 which completely failed to install... not a good sign for Windows users. Anyway.
Quick answer: Change the account in the Windows Services panel from Network to Local.
Details of my case
During installation I created/selected a data folder in the user profile folder, because obviously the folder suggested by default, within the program folder, wouldn't work, and if it worked it would be a very idea to put data here (I don't know whether it's usual to do that on Unix/Linux, but for Windows it's it's not allowed for a long time).
At the end (when populating the data cluster) I received an error:
Failed to load SQL Modules into database Cluster
but the installation was able to complete. I found two pages about previous error, here and here, but they didn't seem relevant to my case, so I just started pgAdmin and, on the left "browser", saw the server wasn't active.
I tried to start it from here (had to type the main password), but it went inactive immediately again. So I tried to use the Windows services panel to start "postgresql-x64-10", no joy. I copied the command from this panel and pasted it into a Windows console (cmd.exe) where I finally received this
error 1063.
Searching I found this related question, and was convinced the problem was about permissions.
Solution working for my case
In the services panel I changed the account used to start the service from Network Service to Local System as suggested in a comment by #AlexanderRios.
sc create "postgresql-9.2" binPath= "\"C:/Program Files (x86)/PostgreSQL/9.2/bin/pg_ctl.exe\" runservice -N \"postgresql-9.2\" -D \"C:/Program Files (x86)/PostgreSQL/9.2/data\" -w" DisplayName= "postgresql-9.2" start= auto
Try this on CMD run as Administrator
(Add your parameters depend on your version)
Stop all postgres processes
Go to the postgres data folder (C:\Program Files\PostgreSQL\9.6\data)
Delete the postmaster.opts and postmaster.pid files
From the control panel, in administrative
tools and the services console start the postgres service
open pgAdmin III and then in right pane find server then just right click and connect, enter the password. after connected go to the browser and refresh ODOO. Problem solved.
See image to get better understanding