PostgreSQL错误的所有权

时间:2015-02-15 05:12:07

标签: ruby-on-rails postgresql permissions postgresql-9.4

我之前提到的事实是我还没有使用过PostgreSQL。我尝试将它与RoR一起使用,但事实上它使用了ORM,我从未得到为什么 PostgreSQL是首选的风格。

在Ubuntu 14.04上安装该死的东西后,我需要克隆一个依赖它的回购。

在尝试了几件事后约30分钟,我发现:

$ /usr/lib/postgresql/9.4/bin/postgres -d 3 -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf 
LOG:  skipping missing configuration file "/var/lib/postgresql/9.4/main/postgresql.auto.conf"
2015-02-14 21:05:01 PST [7665-2] FATAL:  data directory "/var/lib/postgresql/9.4/main" has wrong ownership
2015-02-14 21:05:01 PST [7665-3] HINT:  The server must be started by the user that owns the data directory.
2015-02-14 21:05:01 PST [7665-4] DEBUG:  shmem_exit(1): 0 before_shmem_exit callbacks to make
2015-02-14 21:05:01 PST [7665-5] DEBUG:  shmem_exit(1): 0 on_shmem_exit callbacks to make
2015-02-14 21:05:01 PST [7665-6] DEBUG:  proc_exit(1): 0 callbacks to make
2015-02-14 21:05:01 PST [7665-7] DEBUG:  exit(1)

其中一个,我不知道它正在寻找的auto.conf文件是什么,因为我指定了conf文件。

然而......(编辑到我认为合适的行[s])

$ sudo gedit /etc/postgresql/9.4/main/pg_hba.conf 

local   all             postgres        127.0.0.1               peer

(我在没有工作的情况下添加了本地IP。仍然无法正常工作。)

和(/etc/postgresql/9.4/main/

-rw-r--r-- 1 postgres postgres   315 Feb 14 20:20 environment
-rw-r--r-- 1 postgres postgres   143 Feb 14 20:20 pg_ctl.conf
-rw-r----- 1 postgres postgres  4641 Feb 14 20:55 pg_hba.conf
-rw-r----- 1 postgres postgres  4641 Feb 14 20:20 pg_hba.conf~
-rw-r----- 1 postgres postgres  1636 Feb 14 20:20 pg_ident.conf
-rw-r--r-- 1 postgres postgres 21461 Feb 14 20:20 postgresql.conf
-rw-r--r-- 1 postgres postgres   378 Feb 14 20:20 start.conf

我觉得配置文件归postgres所有。是什么给了什么?

更新(9:30p)

运行以下命令(如postgres)会得到相同的结果。

$ su - postgres; /usr/lib/postgresql/9.4/bin/postgres -d 3 -D /var/lib/postgresql/9.4/main -c config_file=/etc/postgresql/9.4/main/postgresql.conf

1 个答案:

答案 0 :(得分:1)

从错误消息判断,数据目录的所有权似乎配置错​​误。如果是,请修复(作为特权系统用户):

chown postgres:postgres /var/lib/postgresql/9.4
chown postgres:postgres /var/lib/postgresql/9.4/main

如果这些目录中的任何内容归不同用户所有,请使用“递归”选项-R