christo
christo

Reputation: 127

PostgreSQL 9.4 + Windows 7 - Server Not Started

I newly installed PostgreSQL 9.4 onto my Windows 7 os laptop.

Straight afterwards, I think I saw on services.msc a service: postgresql-9.4 PostgreSQL Server 9.4. However, this had a message something along the lines of "marked for deletion".

Didn't understand that and being ignorant I restarted the laptop after the install, expecting magic on the reboot.

Now I can no longer see on any such service available to Start or Stop. I only have a PostgreSQL Scheduling Agent service.

I also have a problem starting and stopping the PostgreSQL Server. For instance, the typical advice seems to be:

NET START postgresql (this doesn't work on mine, because there's no service)

"pg_ctl" -D "C:/Program Files/Postgresql/9.4/data" -l logfile start (uff..I'd much prefer just to click 'start' in services.msc, ala SQL Server. Plus sometimes this gives me an error Another service might be running. Access denied and I can't find the other service, and resmon shows no port usage.)

I've also tried clicking on just about every .exe file in the binaries folder (eg. postgres.exe). But no joy.

I've read that PostgreSQL and Windows are not typically combined, but I'm stuck with Windows due to high use of Office products. Hence, mind if I ask for any construction suggestions on how to fix this issue?

Ideally I'd love to hear a way to get that postgreSQL-x64-9.4 service permanently running in my services.msc.

Many thanks in advance!

Upvotes: 0

Views: 6485

Answers (2)

user330315
user330315

Reputation:

You can re-create the service manually using pg_ctl

Remove the old service:

pg_ctl unregister -N postgreSQL-x64-9.4 

(replace postgresql with the actual service name)

Create a new service

pg_ctl register -N postgreSQL-x64-9.4 -D "C:/Program Files/Postgresql/9.4/data"

Note that it's not a good idea to put the data directory into Program Files. This is an extremely stupid choice of the installer and I don't understand why it's still doing that (I stopped using the installer years ago - I only unzip the archive and then run initdb manually)

c:\Program Files is a restricted directory where only the administrator account is allowed to write to. The Postgres service runs as a regular account and cannot write into that directory. In general you will have a lot less problems if you move the data directory somewhere else.

Upvotes: 1

christo
christo

Reputation: 127

Ah...thanks Simo!

Because I hadn't yet created any databases, I ran the installer again and that started the server and it now appears again in services.msc. So it solved my immediate issue.

Although still curious about what to do if server disappears again. Hence, if anyone has a better solution than this scorched earth approach, that would be of interest.

Many thanks again.

Upvotes: 0

Related Questions