Ubuntu psql:无法连接到服务器 [英] Ubuntu psql: could not connect to server

查看:62
本文介绍了Ubuntu psql:无法连接到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地安装了 postgresql.它没有开始,正如我所知道的:

I have a local installation of postgresql. It does not start, as I get:

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

好的,权限有问题.让我们看看它们:

Ok, something wrong with the permissions. Lets look at them:

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.如何解决?

I found the following: doing sudo chmod 777 /var/run/postgresql solves the problem and a can start postgresql afterwards. Unfortunatly this has to be done after every reboot of Ubuntu. SO two questions: 1.Whats wrong? Why is the chmod not permanently? 2. How to fix it?

谢谢!

推荐答案

好的,我找到了解决方案.删除、清除和重新安装 postgresql 并没有解决问题.我认为早期版本的一些人工制品仍然存在(例如,我仍然在/etc/postgresql/中发现 9.1、9.3 和 9.4 作为子目录).这是我为设置全新安装所做的全套命令:

Ok, I found a solution. A remove, purge and reinstall of postgresql did not solve the problem. I think some artefacts of earlier versions still remained (as I, for instance, still found 9.1,9.3 and 9.4 as subdirectories in /etc/postgresql/). Here is the full set of commands that I did to set up a clean installation:

sudo apt-get remove postgresql
sudo apt-get purge postgresql
apt-get --purge remove postgresql\*
sudo apt-get --purge remove postgresql\*
sudo rm -r /etc/postgresql/
sudo rm -r /etc/postgresql-common/
sudo rm -r /var/lib/postgresql/
sudo rm -r /var/run/postgres
userdel -r postgres
sudo userdel -r postgres
sudo apt-get install postgresql

此后,问题不再存在.

这篇关于Ubuntu psql:无法连接到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆