psql: could not connect to server: No such file or directory&&PGHOST
来源:互联网 发布:php登陆后显示用户名 编辑:程序博客网 时间:2024/05/30 02:23
由于环境变量 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-> psqlpsql: 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-> psqlpsql: 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/pgdatapsql (9.5.7)Type "help" for help.postgres=# 或者在环境变量里添加:export PGHOST=/home/postgres/pgdata然后应用环境变量,再使用psql直连:postgres@pgdb-> psqlpsql (9.5.7)Type "help" for help.postgres=#
By 狮子歌歌
阅读全文
0 0
- 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
- psql: could not connect to server: No such file or directory
- Error getting authority: Error initializing authority: Could not connect: No such file or directory
- Error getting authority: Error initializing authority: Could not connect: No such file or directory
- Error getting authority: Error initializing authority: Could not connect: No such file or directory
- Could not launch app - No such file or directory Error
- Could not stat /dev/sda4 --- No such file or directory
- mysql could not read contents of failed to open no such file or directory
- QScreenLinuxFb::connect: No such file or directory
- Apache 不能启动,出现 No such file or directory: make_sock: could not bind to port 8080 错误
- startx报错xinit: No such file or directory (errno 2): unable to connect to X server xinit: No such pr
- .xsession-errors:openConnection: connect: No such file or directory cannot connect to brltty at :0
- httpd: Could not open configuration file /xxx/conf/httpd.conf: No such file or directory
- Could not open file ..\output\core_cm3.o: No such file or directory
- Ubuntu14 Could not open file /var/lib/dpkg/status - open (2: No such file or directory)
- error: could not lock config file E:/git/Git/%USERPROFILE%/.gitconfig: No such file or directory
- Apache启动错误:No such file or directory httpd: could not open error log file......
- Matlab 关于彩色图像的平移、旋转以及对称处理
- 35. Search Insert Position 查找插入位置
- 小白每天学习两个函数D5-(fseek,ftell)
- 利用Kibana图表化Elasticsearch中的数据
- Ubuntu16.04禁用ipv6
- psql: could not connect to server: No such file or directory&&PGHOST
- 算法训练 字符串变换
- CEF3之js与c++交互问题解决资料
- PhantomJS初识
- Android Studio Opengl Cmake 配置 编译 jni c++ 调用opengl
- EasyX中loadimage函数和putimage函数如何调用
- redis启动报错解决
- Java Set
- C语言练习题(7)