PostgreSQL 服务器启动失败,无法创建锁定文件 : permission denied

标签 postgresql ubuntu ubuntu-13.10

我正在尝试安装和运行一个 postgreSQL 服务器,每当我安装它时使用

sudo apt-get install postgresql

我收到以下错误:

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

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

最佳答案

更改/var/run/postgresql 的所有者并将其设置为postgres:

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

如果您运行的用户没有 sudo 权限,则

  1. 更改为根:

    su -
    
  2. /var/run/postgresql 的所有权更改为用户 postgres 和组 postgres:

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

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

关于PostgreSQL 服务器启动失败,无法创建锁定文件 : permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22851352/

相关文章:

c++ - Gobby 0.4.12安装报错

ruby-on-rails - Rails:fe_sendauth:Ruby 未提供密码 (PG::ConnectionBad),但在 Rails 中正常

postgresql - 如何为 postgresql 启动修复 pgAdmin 4 url

session - Ubuntu 13.10 打破 NoMachine

ubuntu - 完全重新安装ubuntu服务器

bash - 在 ubuntu 终端中将连续图像从 bmp 转换为 png

C++ - 类没有命名类型

php - 多用户应用程序中的 Postgresql 和 PHP : is the currval a efficent way to retrieve the last row inserted id,?

postgresql - 每个唯一值执行一次函数

eclipse - Eclipse Kepler 在关闭之前被阻塞。如何避免这个恼人的问题?