简体   繁体   中英

FATAL: could not create lock file “postmaster.pid”: Permission denied

I receive error

FATAL:  could not create lock file "postmaster.pid": Permission denied

when trying to execute command

pg_ctl restart --pgdata "D:\Program Files\PostgreSQL\8.3\data"

Full rights for postgres user to D:\\, D:\\Program Files\\, D:\\Program Files\\PostgreSQL\\ and D:\\Program Files\\PostgreSQL\\8.3\\data are set. What else I need to do?

I set full access to D:\\Program Files\\PostgreSQL\\8.3\\data to Users group and now it works. Detail are at http://forumserver.twoplustwo.com/114/pokertracker/cant-connect-db-422617/ (last post).

You need to ensure that the user postgres has write permission to the postgres data_directory configured in postgresql.conf file. In my case /var/lib/postgresql/9.5/main/ if not add permission with:

chmod u+w /var/lib/postgresql/9.5/main/

You have to make ensure that the user postgres has right to write & execute /var/run/postgresql

sudo chmod 765 /var/run/postgresql  
sudo chown postgres /var/run/postgresql

I had this issue due to installing postgres-xc and the solution was to remove it.

pg_ctl is the most common (and recommended) way used to start/stop/etc postgres.

For some reason it was not part of my postgres install.
After duckduckgo'ing a little, I installed postgre-xc which includes pg_ctl.
postgres-xc changed the owner of /var/run/postgresql from postgres to postgres-xc.
This caused lots of headaches and warnings about being unable to lock the pid file.

So, I removed postgres-xc (and reverted the owner of /var/run/postgresql to postgres).

Instead of using pg_ctl, I control postgres using

service postgresql status
or
/etc/init.d/postgresql status .

Hopefully this will help someone.

postgresql serviceNETWORK SERVICE登录,因此您必须使数据目录(即: "D:\\Program Files\\PostgreSQL\\8.3\\data" )完全控制到NETWORK SERVICE组。

I just added my username to group "postgres"; all went fine

sudo adduser your-user-name postgres

Ciao

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM