zoukankan      html  css  js  c++  java
  • 问题解决: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 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 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 连接

    为人:谦逊、激情、博学、审问、慎思、明辨、 笃行
    学问:纸上得来终觉浅,绝知此事要躬行
    为事:工欲善其事,必先利其器。
    态度:道阻且长,行则将至;行而不辍,未来可期
    转载请标注出处!
  • 相关阅读:
    Android SDCard操作(文件读写,容量计算)
    weibo4
    weibo5
    android源码结构分析
    后台退出事件
    获取服务器和客户端信息
    vs2008破解升级
    禁止所有蜘蛛
    页面的回发与回传
    显示上一条新闻 下一条新闻
  • 原文地址:https://www.cnblogs.com/ios9/p/15544892.html
Copyright © 2011-2022 走看看