zoukankan      html  css  js  c++  java
  • PGsql 基本用户权限操作

    Ⅰ. 安装与初始账户密码修改

    1. 安装

    sudo apt-get install postgresql-9.4

    2. 管理员身份打开pg

    sudo -u postgres psql

     sudo -u postgres 表示以postgres 用户身份登录

    PostgreSQL数据默认会创建一个postgres的数据库用户作为数据库的管理员,密码随机;

    3.  修改密码

    ALTER USER postgres WITH PASSWORD '123456'; 

    Ⅱ. 修改指定用户指定权限

    alter user postgres superuser createrole createdb replication;

    注意:如果出现 FATAL: role '...' is not permitted to log in.  的错误

    alter user postgres superuser createrole createdb replication login;

    在授权后面加入login 即可;

    Ⅲ. 数据库更改属于postgres用户

    postgres=# alter database database_name OWNER TO new_user;

    IV. 修改PostgresSQL数据库配置实现远程访问

    vi /etc/postgresql/9.4/main/postgresql.conf

    1.监听任何地址访问,修改连接权限

    #listen_addresses = 'localhost'      改为 listen_addresses = '*'

    2.启用密码验证

    #password_encryption = on 改为 password_encryption = on
    vi /etc/postgresql/9.4/main/pg_hba.conf

    在文档末尾加上以下内容

    host all all 0.0.0.0 0.0.0.0 md5

    6、重启服务

    /etc/init.d/postgresql restart

    7、5432端口的防火墙设置 ( Iptable版)

    5432为postgreSQL默认的端口

    iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT

     

  • 相关阅读:
    BZOJ 2002 [Hnoi2010]Bounce 弹飞绵羊 ——Link-Cut Tree
    BZOJ 2049 [Sdoi2008]Cave 洞穴勘测 ——Link-Cut Tree
    hdu
    hdu
    hdu
    hdu
    hdu
    hdu
    hdu
    hdu
  • 原文地址:https://www.cnblogs.com/jokerjason/p/9389526.html
Copyright © 2011-2022 走看看