错误提示:

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"?

出现该问题的很多,以下是目前碰到的几种情况,之后碰到继续补充:

1.删除了/tmp路径中的.s.PGSQL.5432 与.s.PGSQL.5432.lock文件

 解决:重启数据库 $sudo service postgresql restart 

2.修改监听端口:之前用5434监听,后来改为5432,数据库启动,但是psql无法进入数据库,通过psql -p 5432可以进入。

 解决:安装时配置了端口PGPORT。修改~/.bash_profile或/etc/profile文件中的端口指定。

3.修改了postgresql.conf 中的unix_socket_directories

分析见两篇博文:
http://francs3.blog.163.com/blog/static/40576727201332594924829/
http://blog.csdn.net/huguangshanse00/article/details/40413549

引用其中:
"先来看看 socket 文件 "/tmp/.s.PGSQL.1921",其中 1921 是 pg 的端口号;

socket 文件可以通过postgresql.conf 文件以下参数配置:

#unix_socket_directory = ''
#unix_socket_permissions = 0777

备注:其中参数 unix_socket_directory 用来配置 socket 文件的目录,默认是 /tmp 目录参数 

unix_socket_permissions 用来设置 socket 文件的权限。"
        
解决方法:指定host,用psql -h 连接 

问题解决: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"?的更多相关文章

  1. 问题解决: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"?

    错误提示: psql: could not connect to server: No such file or directory Is the server running locally and ...

  2. libpqxx接口的在linux下的使用,解决psql:connections on Unix domain socket "/tmp/.s.PGSQL.5432"错误

    在项目中使用postgresql数据库时要求在windows和linux双平台兼容.于是在windows下使用的接口在linux下爆出异常: psql:connections on Unix doma ...

  3. psql: could not connect to server: No such file or directory&&PGHOST

    由于环境变量 PGHOST配置不当引起的 postgres@pgdb-> psql psql: could not connect to server: No such file or dire ...

  4. psql: could not connect to server: No such file or directory

    postgresql报错: psql: could not connect to server: No such file or directory         Is the server run ...

  5. 解决:error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'

    在使用 deamon@deamon-H55M-S2:/usr/bin$ mysqladmin -u root -p shutdown 关闭MySQL之后试图通过: deamon@deamon-H55M ...

  6. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)-mysql.sock丢失解决方案

    我们的LAMP是搭建在UBUNTU 12.04 LTS上的. LAMP是通过编译的方式进来安装的. 在一次处理意外挂机时由于未知的原因在重启后发现无法连接数据库了, 在打开网站时出现如下的的提示: E ...

  7. Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决

    安装上mysql后,报 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock',试了网上的方法 ...

  8. OperationalError: (2002, “Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)”)

    OperationalError: (2002, “Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld ...

  9. Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock’

    今天服务器遇到了一个很熟悉的问题 输入 #mysql -u root -p ERROR 2002 (HY000): Can't connect to local MySQL server throug ...

随机推荐

  1. Kali Linux 2020.1安装以及安装后要做的事

    Kali Linux是基于Debian的Linux发行版,预装了许多渗透测试软件,让大家从各种繁琐的软件安装中解脱出来,专注于测试本身. 本文章介绍了如何安装目前最新的2020.1版本,以及安装好后补 ...

  2. 00008 - layui 表单验证,需要验证,但非必输

    当使用layui的验证规则,比如 手机, <input type="text" name="userName" lay-verify="phon ...

  3. Gym101635C Macarons

    题目链接:http://codeforces.com/gym/101635/attachments 题目大意: 给出一个 \(N \times M\) 的网格图,请你用 \(1 \times 1\) ...

  4. POJ1930

    题目链接:http://poj.org/problem?id=1930 题目大意: 给一个无限循环小数(循环节不知),要求你输出当该小数所化成的最简分数分母最小时所对应的最简分数. AC思路: 完全没 ...

  5. 11_ArrayList集合的方法

    class Program { static void Main(string[] args) { //数组:长度不可变,类型单一 //ArrayList集合:长度可以任意改变,类型可以不单一 //创 ...

  6. 织梦系统dedecms实现列表页双样式,列表样式循环交替变化

    有时候做列表页需要交替变换样式,那如何实现列表页双样式呢? 在DeDeCMS里面有这样一个函数,可以循环赋予html代码不同的样式,如下: [field:global function=MagicVa ...

  7. Kivy中ActionBar控件的使用

    这个控件可以作为导航栏来使用,效果非常好. 1. ActionBar包含的组件 ActionBar中需要一个ActionView作为容器来存放其他控件,比如:ActionPrevious.Action ...

  8. 域对象的作用范围 & 请求的转发和重定向

    1. 和属性相关的方法: ①. 方法 void setAttribute(String name, Object o): 设置属性 Object getAttribute(String name): ...

  9. 轻松实现记录与撤销——C#中的Command模式

    Command模式属于行为模式,作为大名鼎鼎的23个设计模式之一,Command模式理解起来不如工厂模式,单例模式等那么简单直白.究其原因,行为模式着重于使用,如果没有编程实践,确实不如创造模式那么直 ...

  10. jQuery-键值对理解

    1.form表单 <form action='url' method='get/post'> <input type='text'/> <input type='pass ...