且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows中将PostgreSQL作为服务运行?

更新时间:2023-10-21 12:59:40

问题已解决
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.