PostgreSQL服务器无法启动,无法创建锁定文件:权限被拒绝

daw*_*iaz 40 postgresql ubuntu ubuntu-13.10

我试图安装并运行postgreSQL服务器,每当我使用它安装它

sudo apt-get install postgresql
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

* Starting PostgreSQL 9.1 database server                                       
* The PostgreSQL server failed to start. Please check the log output:
2014-04-03 17:18:16 PDT FATAL:  could not create lock file     "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
                                                                    [fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing postgresql-common (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of postgresql-9.1:
postgresql-9.1 depends on postgresql-common (>= 115~); however:
Package postgresql-common is not configured yet.

dpkg: error processing postgresql-9.1 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of postgresql:
 postgresql depends on postgresql-9.1; however:
  Package postgresql-9.1 is not configured yet.

dpkg: error processing postgresql (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a          previous failure.
Errors were encountered while
 processing:
 postgresql-common
 postgresql-9.1
 postgresql
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

我猜这是一个权限问题; 我该怎么解决呢?我正在运行Ubuntu 13.10

Jes*_*ang 74

检查/ var/run/postgresql的所有者并将其设置为postgres(如果尚未设置).为此,请键入

sudo chown -R postgres:postgres /var/run/postgresql

如果您正在运行的用户没有sudo权限,那么

1)更改为root

su -

2)将/ var/run/postgresql的所有权更改为postgres用户和postgres组

chown -R postgres:postgres /var/run/postgresql

在Ubuntu 14.04上安装postgres时遇到同样的问题,更改所有权为我解决了问题.

  • 在 Fedora 上,将所有者更改为 `postgres:postgres` 对我来说不起作用,但将其更改为我当前的用户有效 `sudo chown -R $USER:$USER /var/run/postgresql` (3认同)

Mat*_*att 17

锁定文件最终进入/var/run.要修复此目录的权限,我需要运行sudo chmod a+w /var/run/postgresql.


new*_*min 2

你能检查一下/var/run的文件权限吗?

ls -l /var/run
Run Code Online (Sandbox Code Playgroud)

如果缺少“写入”权限,请尝试

sudo chmod o+w /var/run
Run Code Online (Sandbox Code Playgroud)