zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    android开发 退出程序
    armeabi和armeabi-v7a引起的问题
    我的博客
    第二章 应用层(一) 应用层概览
    第一章 计算机网络和因特网
    Linux学习笔记——第一篇——Ubuntu安装与操作
    怒学Python——完结篇——I/O
    怒学Python——第四篇——函数与模块
    怒学Python——第三篇——结构控制
    怒学Python——第二篇——类型与运算
  • 原文地址:https://www.cnblogs.com/error500/p/3305956.html
Copyright © 2011-2022 走看看