如何在Windows中将PostgreSQL作为服务运行? [英] How to run PostgreSQL as a service in windows?

查看:417
本文介绍了如何在Windows中将PostgreSQL作为服务运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7 32位操作系统中安装了postgreSQL二进制文件;我可以从cmd启动服务器,但我不能将其作为Windows服务运行。

I installed postgreSQL binaries in windows 7 32bit operating system; I can start the server from cmd but I cant run it as a windows service.

这是我的错误在尝试手动启动该服务时得到以下提示:

"The postgreSQL service on local computer started and then stopped. some services stop automatically if they are not in use by other servces or programs"

我需要做的所有事情是;双击我的Java应用程序启动到Windows后,我需要流畅地运行我的应用程序而没有任何数据库错误。我不能这样做,因为postgreSQL不能作为Windows服务运行。

All I need to do is; after booting to windows when I double clicked my java application I need to run my app smoothly without any database errors. I cannot do this because postgreSQL is not running as a windows service.

我在Windows事件查看器中发现了这一点:

I found this in windows event viewer:

The description for Event ID 0 from source PostgreSQL cannot be found.
Either the component that raises this event is not installed on your local computer or the installation is corrupted.
You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event: 

postgres cannot access the server configuration file 
"C:/Windows/system32/pgsql/data/postgresql.conf": No such file or directory

我在Google上进行了搜索,但找不到答案

I googled about it but I was not able to find an answer.

推荐答案

问题已解决
Windows服务文件中数据目录的路径错误。

Problem was solved path to the data directory was wrong in windows service file.

因此我从这种方法中删除了服务文件:

So I delete the service file from this method:

1)运行Regedit或Regedt32。

1)Run Regedit or Regedt32.

2)转到注册表项 HKEY_LOCAL_MACHINE / SYSTEM / CurrentControlSet / Services

2)Go to the registry entry "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"

3)查找要删除的postgreSQL服务并将其删除。

3)Look for the postgreSQL service that you want delete and delete it.

4)重新启动计算机。

4)reboot the computer.

之后,打开cmd (以管理员身份运行)转到postgreSQL bin目录并运行以下命令:创建一个新的Windows服务:

After that open the cmd (Run as administrator) Go to the postgreSQL bin directory and run this command to create a new windows service:

pg_ctl.exe register -N "PostgreSQL" -U "NT AUTHORITY\NetworkService" -D "C:/Program Files/postgresql/pgsql/bin/pgsql/data" -w

为了我。希望这会有所帮助。

This worked for me. Hope this will help.

这篇关于如何在Windows中将PostgreSQL作为服务运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆