错误提示:

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. RAID0、RAID1及RAID5的区别详解

    目前已有的RAID(Redundant Array of Independent Disks,独立冗余磁盘阵列)技术有很多种,但是RAID0.RAID1.RAID5是最常见的几种方案. 1 RAID0 ...

  2. 2017-ACM南宁网络赛

    In this problem, we will define a graph called star graph, and the question is to find the minimum d ...

  3. poj3613 求经过n条边的最短路 ----矩阵玩出新高度 。

    For their physical fitness program, N (2 ≤ N ≤ 1,000,000) cows have decided to run a relay race usin ...

  4. zqt_helper 轻松开发Qt5 Widgets应用

    目标: 1. 代码更加紧凑,所写即所到. 2. 代码层次更直观,直接反映界面窗口层次关系. 3. 不继承类,不重写虚函数,slot接收QEvent. 4. 简单写布局,忘掉api函数. 5. 免去一大 ...

  5. 基于postman测试接口(整套接口测试)

    基于postman测试接口(整套接口测试) 可以解决的问题 几百个接口人工测试接口过于繁杂 大多测试无法使用请求结果当参数 可以使用随机参数 支持swagger信息导入 随账号持久化保存数据 对集合一 ...

  6. spring的mybatis-puls 配置,增删改查操作,分页

    pom <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.or ...

  7. [工具-004]如何从apk中提取AndroidManifest.xml并提取相应信息

    跟上一篇类似,我们也需要对APK的一些诸如umengkey,ADkey,TalkingData进行验证,那么我们同样需要解压apk文件,然后提取其中的AndroidManifest.xml.然后解析x ...

  8. [Python基础]009.os模块(1)

    os模块(1) 介绍 os 常量 文件目录操作 文件属性操作 遍历文件夹 介绍 os模块是系统服务应用程序接口,是Python最常用的模块之一. os模块包含了对文件和文件夹的操作,操作系统相关的操作 ...

  9. 关于同一密码使用generate_password_hash生成不同的密码散列值

    在python的 werkzeug.security 库中有两个函数generate_password_hash与check_password_hash用于对密码明文生成散列值以及检查密码是否与提供的 ...

  10. 获取<input type="radio">被选中的内容

    背景: <input type="radio">,该标签表示的是单选按钮,这个类型相对于其他类型的获取,比较特殊,特此记录一下. 获取方式: 1. 使用选择器直接获取( ...