将PostgreSQL 9.0注册并运行为Windows服务 [英] Register and run PostgreSQL 9.0 as Windows Service
问题描述
有一段时间我让数据库在命令窗口上运行,因为我没有弄清楚如何将其作为Windows服务运行。
For a while i have my db running on a command window because im not figuring out how to run it as a windows service.
因为我有zip文件版本已下载。我如何将pg_ctl命令注册为Windows服务?
Since i have the zip file version downloaded. how can i register the pg_ctl command as a windows service?
顺便说一句,即时通讯使用以下行来启动服务器:
By the way, im using the following line to start the server:
"D:/Program Files/PostgreSQL/9.0.4/bin/pg_ctl.exe" -D "D:/Program Files/PostgreSQL/9.0.4/db_data" -l logfile start
谢谢。
推荐答案
对 pg_ctl
程序使用 register
参数。
数据目录不应存储在 Program Files
中,位置为%ProgramData%
是例如
The data directory should not be stored in Program Files
, the location of %ProgramData%
is e.g. a good choice.
pg_ctl.exe register -N PostgreSQL -U some_windows_username -P windows_password -D "%ProgramData%/db_data" ...
在较新版本的Postgres中,不再需要单独的Windows帐户,因此以下内容也足够
In newer versions of Postgres, a separate Windows account is no longer necessary, so the following is also sufficient
pg_ctl.exe register -N PostgreSQL -D "%ProgramData%/db_data" ...
详细信息在手册中: http ://www.postgresql.org/docs/current/static/app-pg-ctl.html
您需要确保目录 D:/ Program Files / PostgreSQL / 9.0.4 / db_data
对您使用 -U
You need to make sure the directory D:/Program Files/PostgreSQL/9.0.4/db_data
has the correct privileges for the windows user you specify with the -U
flag.
Btw:将程序数据存储在 Program Files
中是个坏主意。您应该将数据目录移到 Program Files
之外的某个地方,因为 Program Files
通常对于常规用户非常受限制-使用很好的理由。
Btw: it is a bad idea to store program data in Program Files
. You should move the data directory somewhere outside of Program Files
because Program Files
is usually highly restricted for regular users - with a very good reason.
这篇关于将PostgreSQL 9.0注册并运行为Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!