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';



  • 相关阅读:
    《人月神话》读书笔记二
    正则表达式进阶篇
    Zend Framework学习之自定义认证适配器
    Zend Framework学习之常用校验器
    Zend Framework学习之Zend_Mail
    《人月神话》读书笔记一
    Zend Framework学习之校验器Zend_Validate
    我的第一个C++程序
    Zend Framework学习之Zend_Filter_StripTags
    《黑客与画家》读书笔记三(完结)
  • 原文地址:https://www.cnblogs.com/connected/p/12635678.html
Copyright © 2011-2022 走看看