zoukankan      html  css  js  c++  java
  • PostgreSQL配置

     摘要

    PostgreSQL配置

    1、配置监听

    -bash-4.2$ cd $PGDATA
    -bash-4.2$ ls
    base              pg_commit_ts   pg_logical    pg_serial     pg_subtrans  pg_wal                postmaster.opts
    current_logfiles  pg_dynshmem    pg_multixact  pg_snapshots  pg_tblspc    pg_xact               postmaster.pid
    global            pg_hba.conf    pg_notify     pg_stat       pg_twophase  postgresql.auto.conf
    log               pg_ident.conf  pg_replslot   pg_stat_tmp   PG_VERSION   postgresql.conf
    
    -bash-4.2$ cp postgresql.conf postgresql.conf.bak
    -bash-4.2$ vi postgresql.conf 
    
    listen_addresses = '*'  #监听所有ip

     数据库连接

    -bash-4.2$ cp pg_hba.conf pg_hba.conf.bak
    -bash-4.2$ vi pg_hba.conf
    host    all             all             0.0.0.0/0               md5

    多行参数生效顺序:由上到下

    参数详解


    查看数据库
    -bash-4.2$ psql -l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
     template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
    (3 rows)

    连接数据库

    -bash-4.2$  psql -dpostgres
    postgres=# h 可以查找命令
    postgres=# ?

    创建数据库

    postgres=# create table test(id int);
    CREATE TABLE
    postgres=# dt
            List of relations
     Schema | Name | Type  |  Owner   
    --------+------+-------+----------
     public | test | table | postgres
    (1 row)

    修改密码

    postgres=# alter user postgres with password 'postgres';



  • 相关阅读:
    DS博客作业02--线性表
    DS博客作业01--日期抽象数据类型设计与实现
    C语言博客作业06--结构体&文件
    C语言博客作业05--指针
    C语言博客作业04--数组
    DS博客作业08--课程总结
    DS博客作业07--查找
    06--图
    博客作业05--树
    DS博客作业01--日期抽象数据类型设计与实现
  • 原文地址:https://www.cnblogs.com/connected/p/12635678.html
Copyright © 2011-2022 走看看