zoukankan      html  css  js  c++  java
  • PostgreSQL安装

    一、介绍

    PostgreSQL 可以说是目前功能最强大、特性最丰富和结构最复杂的开源数据库管理系统,其中有些特性甚至连商业数据库都不具备。这个起源于加州大学伯克利分校的数据库,现已成为一项国际开发项目,并且拥有广泛的用户群,尤其是在海外,目前国内使用者也越来越多。

    PostgreSQL 基本上算是见证了整个数据库理论和技术的发展历程,由 UCB 计算机教授 Michael Stonebraker 于 1986 年创建。在此之前,Stonebraker 教授主导了关系数据库 Ingres 研究项目,88 年,提出了 Postgres 的第一个原型设计。

    MySQL 号称是使用最广泛的开源数据库,而 PG 则被称为功能最强大的开源数据库。

    二、安装

    1、编译参数介绍

    --prefix      安装路径

    --with-python 服务器端语言python,涉及到服务器端编程

    --with-libxml  支持xml数据类型

    --with-openssl  安装 openssl

    二、安装

    useradd postgres 
    yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel  python-devel gcc-c++ openssl-devel cmake gcc* readline-devel
    
    #数据目录
    mkdir -p /data/postgres/data
    mkdir -p /data/postgres/logs
    chown -R postgres:postgres /data/postgres/data /data/postgres/logs
    
    
    
    tar xf postgresql-10.0.tar.gz
    cd postgresql-10.0/
    
    ./configure --prefix=/usr/local/postgres --with-python --with-libxml --with-libxslt --with-openssl  --with-zlib 
    
    make && make install
    
    
    vim /etc/profile
    export PGDATA=/data/postgres/data
    export PGHOME=/usr/local/postgres
    export PATH=$PGHOME/bin:$PATH
    
    
    source /etc/profile
    
    #切换用户
    su - postgres
    #初始化数据
    initdb 
    
    #启动
    pg_ctl -D /data/postgres/data -l logfile start
    
    #停止
    pg_ctl stop -D /data/postgres/data 
    
    #重启
    pg_ctl restart -D /data/postgres/data 
    
    
    #登录postgres数据库
    psql -h 127.0.0.1 -d postgres -U postgres
    

      

    三、常用命令

    #配置文件
    /data/postgres/data/postgresql.conf
    
    #登录认证配置文件(默认只允许本机登录127.0.0.1)
    /data/postgres/data/pg_hba.conf 
    host    all             all                    all               password  #使用密码方式登录并允许所有主机连接
    
    
    #修改默认用户名密码
    ALTER USER postgres WITH PASSWORD 'postgres';
    
    
    #创建用户
    CREATE USER test1 WITH PASSWORD'123456'; 
    #创建用户数据库
    CREATE DATABASE test1db; 
    #将test1数据库的所有权限都赋予test1:
    GRANT ALL PRIVILEGES ON DATABASE test1db TO test1;
    
    #登录测试
    psql -h127.0.0.1 -dtest1db -Utest1
    
    
    
    
    
    #权限管理
    du  #查看账号与权限
    
    #授予test1账号对test1db的所有权限
    grant all on database test1db to test1;
    
    
    
    #常用命令
    du  #查看账号与权限
    dt  #列出当前库的所有表
    l   #列出所有数据库
    c 库名   #切换数据库
    d 数据库 #得到所有表的名字
    d 表名 #得到表结构
    

      

  • 相关阅读:
    Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques
    [Reproduced works]MongoDB Unauthorized Access Vulnerability
    PHP build notes
    两个坑-Linux下Network-Manager有线未托管-DNS resolv.conf文件开机被清空
    OS命令注入中的空格
    Honeywords项目——检查密码是否被破解的一种简单方法
    如何判断自己的VPS是那种虚拟技术实现的
    reGeorg v1.0内网流量转发
    配置OWASP的ModSecurity规则
    python 2.6 与 2.4 区别
  • 原文地址:https://www.cnblogs.com/zhangb8042/p/11003526.html
Copyright © 2011-2022 走看看