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:
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
.
Alternatively, start PostgreSQL as operating system user postgres
.
If you installed from source, the directory should probably be '/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?
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
sudo chown postgres /var/run/postgresql
after that pg_ctl was able to create the lock file without problems.
I ran into it with an alpine
docker
image. As it turned out they changed the default:
Using /tmp for sockets allows everyone to spoof a PostgreSQL server.
There are 2 options:
Create the /run/postgresql
dir:
mkdir /run/postgresql && chown postgres: /run/postgresql
Change unix_socket_directories
in postgresql.conf
( unix_socket_directories = '/tmp'
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.