When I try to start postgresql I get an error:
postgres
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
So then I try to set my config file:
postgres -D /usr/local/var/postgres
And I get the following error:
postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": Permission denied
Hmm okay. Next, I try to perform that same action as an admin:
sudo postgres -D /usr/local/var/postgres
And I receive the following error:
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent possible system security compromise. See the documentation for more information on how to properly start the server.
I googled around for that error message but cannot find a solution.
Can anyone provide some insight into this?
For those trying to run custom command using the official docker image, use the following command.
docker-entrypoint.sh
handles switching the user and handling other permissions.Your command does not do what you think it does. To run something as system user
postgres
:To run the command (also named
postgres
!):Your command does the opposite:
It runs the program
postgres
as the superuserroot
(sudo
without-u
switch), and Postgres does not allow to be run with superuser privileges for security reasons. Hence the error message.If you are going to run a couple of commands as system user
postgres
, change the user with:... and
exit
when you are done.If you see this error message while operating as system user
postgres
, then something is wrong with permissions on the file or one of the containing directories.In closing:
pg_ctl
- orpg_ctlcluster
in Debian-based distributions.su
andsudo
.