PostgreSQL数据库启动时socket存储目录的配置是什么
发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,这篇文章主要讲解了"PostgreSQL数据库启动时socket存储目录的配置是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PostgreSQL
千家信息网最后更新 2026年10月31日PostgreSQL数据库启动时socket存储目录的配置是什么
这篇文章主要讲解了"PostgreSQL数据库启动时socket存储目录的配置是什么",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"PostgreSQL数据库启动时socket存储目录的配置是什么"吧!
unix_socket_directories参数默认为/tmp,由于该目录是临时目录,以免误操作,一般设置在其他目录中。
下面把unix_socket_directories设置为/data/pg12,重新启动
[pg12@localhost pg120db]$ grep 'unix' postgresql.conf unix_socket_directories = '/data/pg12' # comma-separated list of directories#unix_socket_directories = '/tmp' # comma-separated list of directories#unix_socket_group = '' # (change requires restart)#unix_socket_permissions = 0777 # begin with 0 to use octal notation[pg12@localhost pg120db]$ [pg12@localhost pg120db]$ pg_ctl restartpg_ctl: PID file "/data/pgsql/pg120db/postmaster.pid" does not existIs server running?trying to start server anywaywaiting for server to start....2019-11-18 18:17:35.123 CST [15542] LOG: starting PostgreSQL 12.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit2019-11-18 18:17:35.123 CST [15542] LOG: listening on IPv4 address "0.0.0.0", port 54322019-11-18 18:17:35.123 CST [15542] LOG: listening on IPv6 address "::", port 54322019-11-18 18:17:35.155 CST [15542] LOG: listening on Unix socket "/data/pg12/.s.PGSQL.5432"2019-11-18 18:17:35.237 CST [15542] LOG: redirecting log output to logging collector process2019-11-18 18:17:35.237 CST [15542] HINT: Future log output will appear in directory "pg_log". doneserver started
尝试连接数据库
[pg12@localhost pg120db]$ psql -d testdbpsql: error: could not connect to server: 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.5432"?
提示找不到socket(默认在/tmp下),可使用指定主机&端口连接
但这样的连接方式不是本地连接
[pg12@localhost ~]$ netstat -anpo|grep psql(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)tcp6 0 0 ::1:52206 ::1:5432 ESTABLISHED 16200/psql keepalive (7207.79/0/0)
设置参数PGHOST,使用本地连接(PGHOST behaves the same as the host connection parameter.)
[pg12@localhost pg120db]$ export PGHOST=/data/pg12[pg12@localhost pg120db]$ psql -d testdbExpanded display is used automatically.psql (12.0)Type "help" for help....[pg12@localhost ~]$ netstat -anpo|grep psql(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)unix 3 [ ] STREAM CONNECTED 876042 15681/psql [pg12@localhost ~]$
或者使用-h指定为socket所在目录
[pg12@localhost ~]$ psql -h /data/pg12Expanded display is used automatically.psql (12.0)Type "help" for help.[local:/data/pg12]:5432 pg12@testdb=# ...[pg12@localhost ~]$ netstat -anpo|grep psql(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.)unix 3 [ ] STREAM CONNECTED 880596 16309/psql [pg12@localhost ~]$
感谢各位的阅读,以上就是"PostgreSQL数据库启动时socket存储目录的配置是什么"的内容了,经过本文的学习后,相信大家对PostgreSQL数据库启动时socket存储目录的配置是什么这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
目录
数据
数据库
存储
配置
学习
内容
参数
主机
就是
思路
情况
所在
文章
方式
更多
知识
知识点
端口
篇文章
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
中关村互联网 科技集团
互联网通讯科技
河南真二互联网科技有限公司
互联网为科技
广州互联网科技公司
云电互联网科技
上海亿帐通互联网科技
科技类的互联网平台
互联网科技股午盘股票涨跌
浙江互联网科技研学营
互联网5g黑科技有哪些
杭州壁岐互联网科技有限公司
互联网媒体平台算高科技产业
哈尔滨屹滨互联网科技有限公司
米聚互联网科技南京有限公司排面
允成互联网科技有限公司融资
互联网科技创新的路径
杭州披云加互联网科技有限公司
卡尔迅互联网科技有限公司
每日互联网科技新闻
互联网公司 科技公司
高科技与互联网
青岛互联网科技公司
互联网科技汛
国外互联网科技网站
互联网之后的科技是什么
贵州叶脉互联网科技有限公司所属行业
广州市恰铎互联网科技有限公司
福州德业互联网科技
重庆科技产业互联网有哪些