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修改密码失败 ...
随机推荐
- s3c2140 开发板笔记
文章目录 原理图补充说明 开机串口输出 开发板硬件配置 参考文档 工具下载 代码下载 安装交叉编译器 编译kernel 制作文件系统 配置nfs 配置smb Minimal client-only S ...
- Unity项目架构设计与开发管理 学习
视频地址:https://v.qq.com/x/page/d016340mkcu.html assetstore save manager
- Hi3520DV200和Hi3520DV300
处理器:V200---arm A9 600M主频V300---arm A7 800M主频 编码解码能力:V200---8路D1或者4路720PV300---8路D1或者4路1080p或者9路720p ...
- openstack--1--基础环境搭建
Openstack介绍 OpenStack是一个由NASA(美国国家航空航天局)和Rackspace合作研发并发起的,以Apache许可证授权的自由软件和开放源代码项目. Openstack包含三大项 ...
- 第2节 常用软件安装-JDK和Tomcat
本文转自:http://blog.sina.com.cn/s/blog_15126e2170102w5o8.html 一.JDK的安装与配置 1.从官网下载jdk,注意是jdk不是jre.最好从官网下 ...
- MongoDB journal与oplog解惑
journal journal 是 MongoDB 存储引擎层的概念,目前 MongoDB主要支持 mmapv1.wiredtiger.mongorocks 等存储引擎,都支持配置journal. M ...
- Docker容器挂载主机目录访问出现Permission denied的解决办法
Docker挂载主机目录,访问相应的文件出现Premission denied的权限访问问题 挂载后,查看相应的文件出现如下的提示: [root@ba471da26d07 soft]# lsls: c ...
- Scala实战
1. Eclipse中设置scala调试器 scala的调试器要选择Scala Application(new debuger)Launcher:开始选择图省事,选择了一个字母少的,亲切的Launch ...
- Go语言加解密--AES简单实践
AES加解密的简单实现,代码如下. package main import ( "crypto/aes" "crypto/cipher" "encod ...
- mysql程序之mysqld_safe详解
mysqld_safe命令 mysqld_safe是在Unix上启动mysqld服务器的推荐方法.mysqld_safe增加了一些安全特性,例如在发生错误时重新启动服务器,并将运行时信息记录到错误日志 ...