我在本地安装了PostgreSQL。但是当我启动它时,出现以下错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
手动启动无效:
sudo /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.4 database server
* The PostgreSQL server failed to start. Please check the log output:
2015-03-09 17:41:39 CET [3769-1] FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
好的,权限有问题。让我们来看一下:
ls -all /var/run/
drwxr-xr-x 27 root root 900 Mar 9 17:36 .
drwxr-xr-x 25 root root 4096 Feb 28 06:19 ..
drwxrwsr-x 3 postgres-xc postgres-xc 60 Mar 9 17:35 postgresql
我发现以下内容:执行
sudo chmod 777 /var/run/postgresql
可以解决问题,然后就能启动postgresql了。不幸的是,每次重启Ubuntu后都需要重新执行该命令。所以有两个问题:
1.出了什么问题?为什么chmod没有永久生效?
2.如何修复它?谢谢!