zoukankan      html  css  js  c++  java
  • postgresql 简单入门

    安装

    https://www.postgresql.org/download/linux/redhat/
    yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
    yum install postgresql11-server postgresql11-contrib

    启动

    /usr/pgsql-11/bin/postgresql-11-setup initdb   # 数据库安装目录: /var/lib/pgsql/11/data/
    systemctl start postgresql-11

    客户端连接

    使用上面方式启动的 postgres, 只监听127.0.0.1:5432, 要通过 psql 连接数据库可以通过如下方式

    su - postgres
    psql

    几个重要文件

    /var/lib/pgsql/11/data/postgresql.conf # 系统全局配置文件

    /var/lib/pgsql/11/data/postgresql.auto.conf # 实时通过 alter system 修改的系统参数会写入这个文件, 优先级高于上面文件,不要手动修改这个文件

    /var/lib/pgsql/11/data/pg_hba.conf

    创建用户,数据库

    create role xiaoming with encrypted password '123456';
    create database mydb with owner = xiaoming template=template0 encoding='UTF8';
    grant all on database mydb to xiaoming with grant option;
    alter role xiaoming with login;

    #添加登录许可,编辑 pg_hba.conf
    host   mydb           xiaoming           0.0.0.0/0               md5

    #重启 postgresql
    systemctl restart postgresql-11.service

    # 登录
    psql -h ip -p 5432 mydb xiaoming

     

  • 相关阅读:
    资料链接韦东山和尚观
    资源共享
    总结
    针对piix4_smbus ****host smbus controller not enabled的解决方法
    详解为什么32位系统只能用4G内存.
    在Server 2008下架设FTP服务器
    C面试题
    删除所有的.svn文件夹
    C语言宏定义技巧
    简单的重复登录控制(java版)
  • 原文地址:https://www.cnblogs.com/txwsqk/p/10523620.html
Copyright © 2011-2022 走看看