[英]Postgresql FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
I try to start postgresql: /usr/pgsql-11/bin/pg_ctl -D appli/postgres/data/ -l logfile start
but I don't understand why I have always this error in my logfile:我尝试启动 postgresql: /usr/pgsql-11/bin/pg_ctl -D appli/postgres/data/ -l logfile start
但我不明白为什么我的日志文件中总是出现此错误:
FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
I tried to change permission but I get always Permission denied:我试图更改权限,但我总是被拒绝权限:
chown -R postgres:postgres /var/run/postgresql
chmod 755 /var/run/postgresql
Edit postgresql.conf
and change unix_socket_directories
back to the factory default value /tmp
.编辑postgresql.conf
并将unix_socket_directories
更改回出厂默认值/tmp
。
Alternatively, start PostgreSQL as operating system user postgres
.或者,以操作系统用户postgres
启动 PostgreSQL。
If you installed from source, the directory should probably be '/tmp'.如果您从源代码安装,该目录可能应该是“/tmp”。 If you installed from a repository, the shipped start-up script should handle the permissions for you.如果您从存储库安装,则附带的启动脚本应该为您处理权限。 Why not use that rather than running pg_ctl yourself?为什么不使用它而不是自己运行 pg_ctl 呢?
I had the same problem and what did it for me was creating the directory "postgresql" which didn't exist previously for some bizarre reason and running我遇到了同样的问题,为我做了什么是创建目录“postgresql”,该目录以前由于某些奇怪的原因不存在并正在运行
sudo chown postgres /var/run/postgresql
after that pg_ctl was able to create the lock file without problems.之后 pg_ctl 能够毫无问题地创建锁定文件。
I ran into it with an alpine
docker
image.我遇到了一张alpine
docker
图像。 As it turned out they changed the default:结果他们改变了默认值:
Using /tmp for sockets allows everyone to spoof a PostgreSQL server.为 sockets 使用 /tmp 允许每个人欺骗 PostgreSQL 服务器。
There are 2 options:有 2 个选项:
Create the /run/postgresql
dir:创建/run/postgresql
目录:
mkdir /run/postgresql && chown postgres: /run/postgresql
Change unix_socket_directories
in postgresql.conf
( unix_socket_directories = '/tmp'
).在postgresql.conf
( unix_socket_directories = '/tmp'
) 中更改unix_socket_directories
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.