Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

postgresql

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?

like image 552
DSblizzard Avatar asked Jan 10 '12 03:01

DSblizzard


4 Answers

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).

like image 180
DSblizzard Avatar answered Oct 22 '22 04:10

DSblizzard


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/
like image 39
Gelberth Amarillo Rojas Avatar answered Oct 22 '22 03:10

Gelberth Amarillo Rojas


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.

like image 7
SamGoody Avatar answered Oct 22 '22 05:10

SamGoody


postgresql serviceis logined in NETWORK SERVICE, so you must needed make data dir(ie: "D:\Program Files\PostgreSQL\8.3\data") is full control over to NETWORK SERVICE group.

like image 5
Zhengkun Gong Avatar answered Oct 22 '22 05:10

Zhengkun Gong