psql: FATAL: no pg_hba.conf entry for host

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:psql: FATAL: no pg_hba.conf entry for host

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

pg远程登录拒绝

C:\Users\Administrator>psql -h 192.168.222.2 -U u_xifenfei -d db_xifenfei
psql: FATAL:  no pg_hba.conf entry for host "192.168.222.1", user "u_xifenfei", database "db_xifenfei", SSL off

解决方法

vi $PGDATA/pg_hba.conf
--加上
host   all             all           192.168.222.0/24          md5
--重启pg服务
-bash-4.2$ pg_ctl stop
waiting for server to shut down.... done
server stopped
-bash-4.2$ pg_ctl start
waiting for server to start....2018-08-05 23:46:08.237 EDT [44173] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2018-08-05 23:46:08.237 EDT [44173] LOG:  listening on IPv6 address "::", port 5432
2018-08-05 23:46:08.239 EDT [44173] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2018-08-05 23:46:08.250 EDT [44173] LOG:  redirecting log output to logging collector process
2018-08-05 23:46:08.250 EDT [44173] HINT:  Future log output will appear in directory "log".
 done
server started

测试远程访问

C:\Users\Administrator>psql -h 192.168.222.2 -U u_xifenfei -d db_xifenfei
用户 u_xifenfei 的口令:
psql (10.4)
输入 "help" 来获取帮助信息.

db_xifenfei=# select version();
                                                 version
---------------------------------------------------------------------------------------------------------
 PostgreSQL 10.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), 64-bit
(1 行记录)
此条目发表在 PostgreSQL 分类目录。将固定链接加入收藏夹。

评论功能已关闭。