pgsql连接设置

  1. 登录pgsql
    psql -h 10.1.146.87 -U username -d dbname
报错如下: psql: could not connect to server: Connection refused Is the server running on host "my host name" (IP) and accepting TCP/IP connections on port 5432?

处理方法: 修改修改postgresql.conf和pg_hba.conf文件 cd /opt/pgsql/data vim postgresql.conf listen_addresses = '*' port = 5432 vim pg_hba.conf host all all 0.0.0.0/0 password 或者 host all all 10.1.146.87/32 trust

【pgsql连接设置】(1)."trust"和"password"为postgresql数据库登陆验证的方式
"trust"表示信任,即不需要输入密码(即使有密码)
"password"表示需要输入密码
(2).host all all 127.0.0.1/31 trust表示本地连接数据库不需要输入密码
(即使有密码,设为trust后就不需要密码)
(3).host all all 0.0.0.0/0 所有主机连接数据库需要输入密码(如果有密码)
(4).当然,这两个综合后表现的结果就是:
对于本机链接表示信任(不需要输入密码)
对于非本机链接需要输入密码
修改防火墙,开放5432端口

  1. 报错

    pgsql连接设置
    文章图片
    Paste_Image.png

    推荐阅读