PostgreSQL 服务器启动失败,无法创建锁定文件:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22851352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PostgreSQL server failed to start, could not create lock file: permission denied
提问by dawsondiaz
I am attempting to install and run a postgreSQL server, whenever I install it using
每当我使用安装它时,我都试图安装和运行 postgreSQL 服务器
sudo apt-get install postgresql
I get the following error:
我收到以下错误:
* 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)
I am guessing it's a permissions issue; how do I go about solving it? I am running Ubuntu 13.10
我猜这是一个权限问题;我该如何解决?我正在运行 Ubuntu 13.10
回答by Jessica Chiang
Check the owner of /var/run/postgresql and set it to postgres if not already so To do so, type
检查 /var/run/postgresql 的所有者并将其设置为 postgres 如果还没有这样做,请键入
sudo chown -R postgres:postgres /var/run/postgresql
sudo chown -R postgres:postgres /var/run/postgresql
If the user you are running as does not have sudo privilege, then
如果您运行的用户没有 sudo 权限,则
1) Change to root
1) 改为root
su -
su -
2) Change ownership of /var/run/postgresql to postgres user and postgres group
2) 将 /var/run/postgresql 的所有权更改为 postgres 用户和 postgres 组
chown -R postgres:postgres /var/run/postgresql
chown -R postgres:postgres /var/run/postgresql
I had the same problem when installing postgres on Ubuntu 14.04 and changing the ownership fixed the problem for me.
我在 Ubuntu 14.04 上安装 postgres 时遇到了同样的问题,更改所有权为我解决了这个问题。
回答by Matt
The lock file ends up in /var/run
. To fix the permissions of this dir, I needed to run sudo chmod a+w /var/run/postgresql
.
锁定文件以/var/run
. 要修复此目录的权限,我需要运行sudo chmod a+w /var/run/postgresql
.
回答by new_sys_admin
Could you check the file permissions of /var/run?
你能检查/var/run的文件权限吗?
ls -l /var/run
If 'write' permission is missing, try
如果缺少“写”权限,请尝试
sudo chmod o+w /var/run