• pg常用命令


    登录
    psql -d postgres -Upostgres -w -p5432
    psql -U postgres -d postgres
    -u 登陆的用户,
    -d 指定登录连接的数据库

    pg的操作:
    退出: q
    列出数据库:psql -l ,l
    select datname from pg_database;
    查看当前连接的数据库和用户: c
    查看所有用户 du
    列出这个数据库的表:d, dt ,dn+
    d pg_tables;
    select * from pg_tables;
    d 表名 查看表结构
    可以设置set search_path to aa;
    (a表示schemas名字)
    查看数据库版本:select version();
    查看版本信息:show server_version;
    查看session信息:select * from pg_stat_activity;
    杀会话:select pg_terminate_backend(pid);
    创建索引:create index inde)x_name on table_name(column_name);
    查看历史操作: s
    查看索引 di

    用管理员用户建库和创建普通用户
    # psql -h 192.168.1.106? -p 5432? -U postgres??

    create user jiayan with password 'Aa!123456';

    create database test1 owner jiayan ;

    grant all privileges on database test1 to jiayan;

    查看字符集:
    encoding
    show client_encoding;

    大小写敏感
    show case_sensitive;

    授权:
    grant postgres to jiayan;

    同步完 d 显示没有表,: dns

    默认schema
    -- Use this to show the current search_path
    -- Should return: "$user",public
    SHOW search_path;

    -- Create another schema
    CREATE SCHEMA my_schema;
    GRANT ALL ON SCHEMA my_schema TO my_user;

    -- To change search_path on a connection-level
    SET search_path TO my_schema;

    -- To change search_path on a database-level
    ALTER database "my_database" SET search_path TO my_schema;

    插入大量数据脚本命令:
    inser into schema.table select generate_series(1,10000),'a';
    以上表中有一列int类型列和一列char型列,generate_series(1,10000)作用为产生数列1、2、3...10000,因此执行完成以上语句后表中会被插入10000条是数据


    PostgreSQL 设置允许访问IP
    https://blog.csdn.net/wlchn/article/details/78915813

    postgresql数据库用户名密码验证失败
    https://blog.csdn.net/pg_hgdb/article/details/78805463

    PostgreSQL的访问控制(pg_hba.conf)
    https://my.oschina.net/liuyuanyuangogo/blog/497239

    Postgresql 远程连接配置
    https://www.cnblogs.com/3Tai/p/4935303.html

    PostgreSQL远程连接配置管理/账号密码分配
    https://yq.aliyun.com/articles/599287

    Postgres password authentication fails
    https://stackoverflow.com/questions/14564644/postgres-password-authentication-fails?rq=1

    https://stackoverflow.com/questions/18664074/getting-error-peer-authentication-failed-for-user-postgres-when-trying-to-ge/26735105#26735105

  • 相关阅读:
    03. DOCKER 服务安装
    07. DOCKER 数据持久化
    06. DOCKER 镜像制作
    04. DOCKER 镜像管理
    如何在Nginx上 安装SSL证书
    全网首个上位机智能框架课程
    上位机与MES对接的几种方式
    再也不用担心窗体变形了
    JUCCAS和AQS
    docker镜像清理小脚本
  • 原文地址:https://www.cnblogs.com/jiayan666/p/14282886.html
Copyright © 2020-2023  润新知