0

The documentation https://www.postgresql.org/docs/13/server-start.html offers this command:

$ postgres -D /usr/local/pgsql/data

But with this command I get the following error:

Running the PostgreSQL server by a user with administrator rights is not allowed. The server must be started with an unprivileged user to prevent any security issue on the server. See the documentation for more information on running the server clean.*

1 Answers1

2

You should be using pg_ctl to start the Server - that ensures that the administrator privileges are dropped during startup.

Something like:

pg_ctl -D c:/Data/PostgresData start

You can register Postgres a Windows service using pg_ctl

The parameters are documented in the manual

pg_ctl register -N postgresql-13 -D c:/Data/PostgresData

That must be done with Administrator privileges.

By default the service is set to automatic start, you can disable that if you want. Then you can start it manually using:

net start postgresql-13

(Again with a privileged Administrator account)

  • Please can you put a link that explains how to install postgres as a Windows service ? The documentation shows several ways to install it. – DONGMO BERNARD GERAUD May 21 '21 at 12:28
  • @DONGMOBERNARDGERAUD: `pg_ctrl register ...` as explained [here](https://www.postgresql.org/docs/current/app-pg-ctl.html) –  May 21 '21 at 12:30
  • Thank you for your help. All commands `$pg_ctl -D "C:\Program Files\PostgreSQL\13\data" option` are working now. After launching the command `$pg_ctl -D "C:\Program Files\PostgreSQL\13\data" start`, the services.msc shows that **postgresql-x64-13 - PostgreSQL server 13** is running. – DONGMO BERNARD GERAUD May 21 '21 at 13:48
  • Putting the data directory (or actually _any_ application data) below `c:\Program Files` is a really bad idea. –  May 21 '21 at 13:56
  • You're right, I had already had some problems with that on android sdk. – DONGMO BERNARD GERAUD May 21 '21 at 14:24