加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL学习第五篇--监听地址及端口修改

发布时间:2020-12-13 17:00:58 所属栏目:百科 来源:网络整理
导读:在数据目录下编辑postgresql.conf文件,找到如下内容:#listen_addresses = 'localhost' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart)#port = 5432
在数据目录下编辑postgresql.conf文件,找到如下内容:
#listen_addresses = 'localhost'         # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost'; use '*' for all
                                        # (change requires restart)
#port = 5432                            # (change requires restart)

其中,参数“listen_addresses”表示监听的IP地址,默认是在localhost处监听,也就是127.0.0.1的ip地址上监听,这会让远程的主机无法登陆这台数据库,如果想从其他的机器上登陆这台数据库,需要把监听地址改为实际网络的地址,一种简单的方法是,把这个地址改为*,表示在本地的所有地址上监听。

参数port表示监听的数据库端口,默认为5332,可以不更改。

修改了这两个参数,需要重启数据库。


原端口:
[postgres@single ~]$ netstat -a | grep PGSQ
unix  2      [ ACC ]     STREAM     LISTENING     40425  /tmp/.s.PGSQL.5432

重启库:
[postgres@single pgdata]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@single pgdata]$ pg_ctl start
server starting
[postgres@single pgdata]$ LOG:  database system was shut down at 2016-11-17 12:19:59 CST
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

现端口:
[postgres@single pgdata]$ netstat -a | grep PGSQ
unix  2      [ ACC ]     STREAM     LISTENING     46201  /tmp/.s.PGSQL.6432

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读