Ubuntu 16.04 安装使用PostgreSQL最佳指南

一、安装

apt install postgresql

二、编辑 /etc/postgresql/9.5/main/postgresql.conf

将下面 listen_addresses = 'localhost'注释去掉并改为  listen_addresses = '*'
# - Connection Settings -
#listen_addresses = 'localhost'          
# what IP address(es) to listen on;                
# comma-separated list of addresses;     
# defaults to 'localhost'; use '*' for all
...

将下面password_encryption = on 注释打开
#password_encryption = on

三、切换用户su - postgres
四、通过 psql 命令进入postgresql客户端
五、修改用户密码:

 ALTER USER postgres PASSWORD '123456';

六、 vim /etc/postgresql/9.5/main/pg_hba.conf 修改 host all all 192.168.1.0/24 md5 中的ip,为:0.0.0.0/0

# TYPE DATABASE  USER    CIDR-ADDRESS     METHOD
# "local" is for Unix domain socket connections only
local all    all               trust
# IPv4 local connections:
host  all    all    127.0.0.1/32     trust
host  all    all    192.168.1.0/24    md5
# IPv6 local connections:
host  all    all    ::1/128       trust

你可能感兴趣的:(Ubuntu 16.04 安装使用PostgreSQL最佳指南)