Register and run PostgreSQL 9.0 as Windows Service

后端 未结 2 1256
梦谈多话
梦谈多话 2020-12-09 18:24

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.

Since i have the zip file version downloaded. ho

2条回答
  •  天涯浪人
    2020-12-09 18:46

    Use the register parameter for the pg_ctl program.

    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" ...
    

    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" ...
    

    Details are in the manual: http://www.postgresql.org/docs/current/static/app-pg-ctl.html

    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: 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.

提交回复
热议问题