Ubuntu任意IP远程连接配置postgresql

  • 下载postgresql
sudo apt-get install postgresql
  • 配置postgresql.conf文件 将listen_addresses = "localhost"改为listen_addresses = "*" 打开password登录(88行左右)
vim /etc/postgresql/9.5/main/postgresql.conf
listen_addresses = "*"

...

password_encryption = on
  • 进入postgresql初始用户postgres  修改密码
su - postgres
psql -U postgres
ALTER USER postgres PASSWORD '123456';
  • 退出数据库 退出postgres用户 修改pg_hba.conf添加host  all    all    0.0.0.0/0    md5
vim /etc/postgresql/9.5/main/pg_hba.conf
# "local" is for Unix domain socket connections only
local all    all               trust
# IPv4 local connections:
host  all    all    127.0.0.1/32    md5
host  all    all    0.0.0.0/0       md5
# IPv6 local connections:
host  all    all    ::1/128         md5
  • 重启postgresql
/etc/init.d/postgresql restart

 

你可能感兴趣的:(数据库配置,postgresql,远程连接,配置数据库)