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 directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.1921"?
若环境变量PGHOST未配置,且psql不加-h命令的时候,则默认使用的是数据库参数unix_socket_directories 的默认值(一般是/tmp)
作为unix-domain-socket路径。
即:psql 相当于 psql -h /tmp
情况1
若环境变量PGHOST未配置,并修改了unix_socket_directories参数,则直接使用psql命令连接会报错:
注:postgres server 是运行状态
postgres@pgdb-> psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.1921"
解决方法:
1.psql命令必须加 -h 选项 并指定 unix-domain-socket的路径(即unix_socket_directories参数所设置的值)
2.或者环境变量里添加PGHOST,其值为unix_socket_directories 路径
过程演示
1.无意修改了unix_socket_directories的默认值,并将其改成了任意目录(这里假设将该参数值设置成/home/postgres/pgdata)
2.则下次使用直接使用psql连接时,便会报错:
postgres@pgdb-> psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.1921"?
3.这时,解决方法如下:
postgres@pgdb-> psql -h /home/postgres/pgdata
psql (9.5.7)
Type "help" for help.
postgres=#
或者在环境变量里添加:
export PGHOST=/home/postgres/pgdata
然后应用环境变量,再使用psql直连:
postgres@pgdb-> psql
psql (9.5.7)
Type "help" for help.
postgres=#
psql: could not connect to server: No such file or directory&&PGHOST的更多相关文章
- 问题解决: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 ...
- 问题解决: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 ...
- 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 ...
- docker 踩坑笔记之 psql: could not connect to server
最近在用docker跑rails,也遇到了一些坑,这里记录一下. 首先build项目: docker-compose build 然后就开始报错了: psql: could not connect t ...
- “psql: could not connect to server: Connection refused” Error when connecting to remote database
问题: I am trying to connect to a postgres database installed in a remote server using the following c ...
- postgresql connection failure:SQLSTATE[08006] [7] could not connect to server: Permission denied Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
PHP 程序无法连接到 CentOS 上的PostgreSQL,但是在 CentOS 服务器上却能正常运行 psql, 操作如下:多次重启 PG 数据库后发现 CGI 脚本无法连接数据库,但是可以使用 ...
- SSH登录之后运行命令报错的解决办法-- Failed to connect to Mir: Failed to connect to server socket: No such file or directory
问题描述: Failed to connect to Mir: Failed to connect to server socket: No such file or directory 解决方案: ...
- LoadRunner执行过程报错“Failed to connect to server "xxx.xxx.xxx.xxx:xx":[10060] connetion time out”
执行性能测试过程中,LR报错: Action.c(6):Error -27796: Failed to connect to server "xxx.xxx.xxx.xxx:xx" ...
- MySQL忘记密码,或:root密码重置报错:mysqladmin: connect to server at 'localhost' failed的解决方案
MySQL root密码重置报错:mysqladmin: connect to server at 'localhost' failed的解决方案 1 登陆失败,mysqladmin修改密码失败 ...
随机推荐
- golang xml parent node add attribute without struct
question: golang encoding/xml: foo>bar,attr - foo ignored solution: you can replace output resul ...
- java_main
Java中用户向系统传递参数的三种基本方式 main方法 在Java中,main()方法是Java应用程序的入口方法,也就是说,程序在运行的时候,第一个执行的方法就是main()方法,这个方法和其他的 ...
- ADB连接手机的两种方式(usb数据线连接和wifi连接)
ADB(Android Debug Bridge)安卓测试桥,它是连接电脑开发端和安卓设备的桥梁,这个安卓设备可以是真实的安卓手机或者平板,也可以是虚拟的安卓模拟器, 这里介绍ADB连接手机的两种 ...
- Qt开发问答
Qt开发问答 1, Difference between Dialog and widget and QMainWindow http://www.qtcentre.org/threads/3465- ...
- mysql之 redo log
重做日志(redo log) 前言:之前一直弄不清楚 mysql 里面 bin log 和 innodb log 文件的区别,在脑子里面一直有个疑问 binlog 日志文件已经可以用来进行数据库的日志 ...
- 怎么检测浏览器有没有flash播放器
虽然现在大多浏览器都支持了HTML5的新特性,可以直接在网页上播放视频,通过<video>标签即可,但是大多数的浏览器对H5支持还是不够完整,或者很多用户还没有把浏览器升级到最新的版本,尤 ...
- spark机器学习
多层感知器(MLP) from __future__ import print_function from pyspark.ml.classification import MultilayerPer ...
- js正则表达式只能是数字、字母或下划线
//只能是数字.字母或下划线 function isValid(str) { var reg = /^\w+$/g; return reg.test(str); }
- thinkphp本地调用Redis队列任务
1.安装配置好Redis 2.进入项目根目录文件夹输入cmd进入命令行 3.输入php think 查看php扩展 4.输入 php think queue:listen 启动队列监听
- 阿里云 CentOS安装Git
一.Git的安装 1. 下载Git wget https://github.com/git/git/archive/v2.8.0.tar.gz 2. 安装依赖 sudo yum -y install ...