Mahdi
Mahdi

Reputation: 11

Can not run PostgreSQL by pg_ctl

I'm new in PostgreSQL, every thing worked fine until unexpected restart, now when I trying to run postgres by this command

>pg_ctl.exe start

it says :

The program "postgres" was found by "C:\Program Files\PostgreSQL\13\bin/pg_ctl.exe" but was not the same version as pg_ctl. Check your installation.

the version of postgres and pg_ctl.exe are same (both of them : 13.1)

[command line image]

1

I've tried another way, I try to run postgres service in windows services it run and stopped immediately and shows a warning
[warning image]

2

so I checked logs(in windows event viewer)and it said :

FATAL: XX000: C:\Program Files\PostgreSQL\13\bin\postgres.exe: could not locate matching postgres executable LOCATION: getInstallationPaths, d:\pginstaller_13.auto\postgres.windows-x64\src\backend\postmaster\postmaster.c:1489

OS : windows server 2019

PostgreSQL Version : 13

Upvotes: 1

Views: 6329

Answers (2)

OpenUtau
OpenUtau

Reputation: 1

Please choose the solution that suits your problem.

The following errors do not necessarily appear on your computer, but this increases the probability of fixing them.

  1. Using American English if psql is going to localize on the current computer.
  2. If you try to install psql on a non-default path using Windows, do not place it outside disk C.
  3. In the last step of the installation, add the postgres user and give it all permissions in the installation path location, which is especially important for initial writes to the data directory.

A good and simple example is to run net user /add so that you can use psql right away.

  1. Do not run default things similar to poshrc in Computer\ HKEY_LOCAL_MACHINE\ Software\ Microsoft\ Command Processor\ Autorun, transfer and move to HKCU!
  • If none of the above methods work, at least we can start it manually by running the following command
.\<Path to PostgreSQL>\<version>\bin\initdb -D "<Path to PostgreSQL>\<version>\data"
.\<Path to PostgreSQL>\<version>\bin\pg_ctl start -D "<Path to PostgreSQL>\<version>\data"

Upvotes: -1

Anton Kudryavtsev
Anton Kudryavtsev

Reputation: 261

In my case I tried all the solutions I found online. None worked. Dozens of reinstall tries.

Then I remembered that I changed one parameter in the registry to better display the local language in cmd.

Returning the value of the command line encoding registry value solved the problem in my case.

Change your registry value to empty:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun

Upvotes: 16

Related Questions