• redhat7.0安装postgresql


    安装命令

    sudo yum install postgresql-server
    
    • 查看安装的包
    sudo yum list postgres* 
    

    postgresql.x86_64
    postgresql-contrib.x86_64
    postgresql-libs.x86_64    
    postgresql-server.x86_64

    sudo su -c " PGSETUP_INITDB_OPTIONS='-U postgres -E UTF8 --locale=zh_CN.UTF-8' postgresql-setup  initdb"
    

    Initializing database ... OK

    sudo systemctl enable postgresql
    

    /etc/systemd/system/multi-user.target.wants/postgresql.service

    sudo systemctl start postgresql
    
    • 切换账号,登录psql
    sudo su postgres
    psql
    

    至此, postgresql安装完成!

    • 使用密码认证,在初始化时考虑加入: PGSETUP_INITDB_OPTIONS = '-auth-host=md5 …' 或者修改
      sudo sed -r -i 's/^(host.*)(ident)/1md5/g'  /var/lib/pgsql/data/pg_hba.conf
    

    数据库配置

    • 登录数据库
    sudo su postgres
    psql
    
    • 设置密码、账号
    postgres=# password postgres
    postgres=# create user keke_zhaokk with password '密码';
    postgres=# create database exampledb owner keke_zhaokk;
    postgres=# grant all privileges on database exampledb to keke_zhaokk;
    postgres=# q
    
    • 用账号密码登录
    psql -U postgres -h 127.0.0.1 -p 5432
    psql -U keke_zhaokk  -d exampledb -h 127.0.0.1 -p 5432
    
  • 相关阅读:
    设计模式之访问者模式
    设计模式之命令模式
    设计模式之迭代器模式
    tomcat8.0.11性能优化
    java 基础 --集合--012
    StringBuffer和StringBuilder的区别
    jquery 入门
    java 基础 --匿名内部类-008
    java 基础 --多态--009
    java 基础--继承--007
  • 原文地址:https://www.cnblogs.com/bregman/p/6223841.html
Copyright © 2020-2023  润新知