• step by step设置postgresql用户密码并配置远程连接


    设置pgsql默认用户posgres的密码

    1、确认pgsql是开启的 /etc/init.d/postgresql status
    2、使用默认用户登录 sudo su postgres
    3、进入psql客户端 命令为 sudo -u postgres psql 进入之后就可以写sql了
    4、执行第三步如果出现“postgres is not in the sudoers file.  This incident will be reported.”提示则需要在sudoers里面加上postgres,步骤如下:
            1) 输入命令 su - 进入超级用户模式(如果当前不是root用户,则进行root身份验证);
            2) chmod u+w /etc/sudoers 为sudoers文件添加写的权限(默认是只读)
            3) vim /etc/sudoers 编辑sudoers文件,在root ALL=(ALL) ALL这一行下面加上 postgres  ALL=(ALL) ALL
            4)撤销sudoers文件可写 chmod u-w /etc/sudoers
    5、继续执行第三步,进入psql客户端之后执行 postgres=# ALTER USER postgres with password '123456';(将默认的postgres用户密码设置为123456,注意语句后面一定要加分号),postgres=# q 退出psql客户端
     

    设置pgsql远程连接

    1、修改pgsql配置文件postgresql.conf(默认位于安装目录的data子文件夹下)。找到 listen_addresses = 'localhost' 这一行,将localhost修改为 * 所有ip都允许连接,并取消注释
    2、port = 5432 取消注释
    3、修改pg_hda.conf(和postgresql.conf同一个目录),在末尾加一行  host    all         all         0.0.0.0/0      md5
    4、开启5432端口:
    iptables -I INPUT -p tcp --dport 5432 -j ACCEPT 
    /etc/init.d/iptables save
    /etc/init.d/iptables restart
  • 相关阅读:
    《C++ Primer》笔记string,vector
    《C++ Primer》笔记创建动态数组new,delete
    《C++ Primer》笔记迭代器iterator
    浅析jQuery基础框架
    linux常用命令
    Javascript常用对象详细讲解
    Javascript兼容多种浏览器
    Vim常用命令
    提高 web 应用性能之 JavaScript 性能调优
    jQuery LigerUI使用教程入门篇
  • 原文地址:https://www.cnblogs.com/error500/p/3305956.html
Copyright © 2020-2023  润新知