pg数据库开启远程连接_如何运行远程客户端连接postgresql数据库
如何運行遠程客戶端連接
postgresql
數據庫
前提條件是
2
個:
1
,
pg_hba.conf
里面配置了運行遠程客戶機連接
pg_hba.conf
配置后需要重新加載
reload
生效。
2
,
默認監聽只監聽本機,需要讓監聽程序來監聽外邊連接的端口。
做法:
1
,配置
pg_hba.conf
配置文件在
/opt/postgres/9.0/data
目錄,備份后,進行
vi
編輯:
#?IPv4?local?connections:
host
all
all
127.0.0.1
/
32
password
host
all
all
192.168.1.0/
24
password
host
all
all
192.168.10.0/
24
password
#
加入這行表示運行
192
這個網段的機
器訪問所有的數據庫。
然后
reload
配置
,指定數據庫的數據的目錄,其實就是
pg_hba.conf
的目錄
[root@fia?~]#?/opt/postgres/
9.0/bin/pg_ctl
reload?-D?/opt/postgres/9.0/data
pg_ctl:?cannot?be?run?as?root
用戶權限不對,
root
也不行
Please?log?in?(using,?e.g.,?"su")?as?the?(unprivileged)?user?that?will
own?the?server?process.
[root@fia?~]#?id
uid=0(root)?gid=0(root)?groups=0(root)
[root@fia?~]#?su?-?postgres
必須用
postgres
用戶才能運行
-bash-3.2$?/opt/postgres/
9.0/bin/pg_ctl
reload?-D?/opt/postgres/9.0/data
server?signaled
2
,監聽程序
PostgreSQL
默認只監聽本地端口,用
netstat?-tuln
只會看到“
tcp?127.0.0.1:5432?LISTEN
”
。
修改
postgresql.conf
中的
listen_address=*
,
監聽所有端口,
這樣遠程才能通過
TCP/IP
登錄數
據庫,
用
netstat?-tuln
會看到“
tcp?0.0.0.0:5432?LISTEN
”
[root@fia?/]#?netstat?-tuln?|grep?5432
tcp
0
0?0.0.0.0:5432
0.0.0.0:*
LISTEN
tcp
0
0?:::5432
:::*
LISTEN
總結
以上是生活随笔為你收集整理的pg数据库开启远程连接_如何运行远程客户端连接postgresql数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 绿绿绿绿绿是哪首歌啊?
- 下一篇: consul服务下线通知_Consul微