美文网首页
Windows远程管理postgresql

Windows远程管理postgresql

作者: 叽翅 | 来源:发表于2018-04-04 17:00 被阅读0次
  • 配置postgresql的pg_hba.conf和postgresql.conf使其能被外网访问
  • 重启postgresql
  • 需要一个图形化管理软件比如Navicat

1、修改pg_hba.conf

路径(这里的9.5要修改为你的pgsql实际版本号):/etc/postgresql/9.5/main/pg_hba.conf
内容:找到如下行

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

在下面添加一行

host    all             all             0.0.0.0/0          md5

2、修改postgresql.conf

路径(这里的9.5要修改为你的pgsql实际版本号):/etc/postgresql/9.5/main/postgresql.conf
内容:在开头第二页左右找到#listen_addresses = ‘localhost’字段把注释#去掉,并修改localhost,使这一行变成listen_addresses = '*'

3、重启postgresql

重启才能让上面的配置生效。百度好多让使用pg_ctl进行重启,可是没有pg_ctl这个命令,也搜不到怎么配置pg_ctl这个命令,怎么办...
那么输入如下命令进行重启

$ sudo service postgresql restart

4、远程管理

http://www.navicat.com.cn/ 下载Navicat
点击连接-PostgreSQL配置要连接的IP地址,端口5432。
初始数据库可以填postgres,不填的话默认是下面的用户名为数据库,如果没有用户名对应的数据库则会报错。
用户名和密码填postgresql的数据库账户和密码而不是Linux系统的用户密码。

5、其他

如果不知道数据库用户名和密码,那么重设一遍

$ psql postgres
postgres=# alter user postgres with password 'xxx';

即可使用用户名postgres,密码xxx来登录

相关文章

网友评论

      本文标题:Windows远程管理postgresql

      本文链接:https://www.haomeiwen.com/subject/orflhftx.html