美文网首页SonarQube
PostgreSQL允许远程登录

PostgreSQL允许远程登录

作者: 戈壁堂 | 来源:发表于2020-07-25 17:39 被阅读0次

    Connecting to a Remote PostgreSQL Database

    默认,PostgreSQL只监听本地连接,不允许远程通过TCP/IP链接,运行远程连接需要在Server端修改两个配置文件;postgresql.confpg_hba.conf文件。

    • postgresql.conf中修改监听配置,修改为 listen_addresses = '*'
    • pg_hba.conf修改权限配置,host all all 0.0.0.0/0 md5
    • 修改完成后,需要重启数据库才能生效。 sudo systemctl restart postgresql-10.service

    这两个配置文件的位置可以在数据库中使用postgres用户通过以下sql进行查询:

    • show config_file;显示 postgresql.conf文件的具体位置
    • show hba_file;显示 pg_hba.conf文件的具体位置
    postgres=# show config_file;
                  config_file
    ----------------------------------------
     /var/lib/pgsql/10/data/postgresql.conf
    (1 row)
    
    postgres=# show hba_file;
                  hba_file
    ------------------------------------
     /var/lib/pgsql/10/data/pg_hba.conf
    (1 row)
    
    postgres=#
    
    

    相关文章

      网友评论

        本文标题:PostgreSQL允许远程登录

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