1

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 Answer 1

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)

Sign up to request clarification or add additional context in comments.

5 Comments

Please can you put a link that explains how to install postgres as a Windows service ? The documentation shows several ways to install it.
@DONGMOBERNARDGERAUD: pg_ctrl register ... as explained here
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.
Putting the data directory (or actually any application data) below c:\Program Files is a really bad idea.
You're right, I had already had some problems with that on android sdk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.