postgres基础知识

postgres是连接到具体的库:
   ./psql -U postgres  不指定库,默认就是用户名的同名库
   ./psql -d chat -U postgres  指定chat库
   
postgres登录权限配置文件是在数据目录下的pg_hba.conf     



\du: 查看用户
\dt: 查看表
\dn:查看schema
\c: 切换连接 如 \c postgres postgres 使用postgres用户连接到postgres数据库
\d: 查看数据库对象
\l:查看数据库

批量给某个用户授权示例
1. 管理员登录: ./psql  -U postgres

2. 创建用户: create user chat with password  'chatpasswd'

3. 给用户授权:
   1. 先登录到需要授权的库下
    ./psql -d chat -U postgres

   2. 查看schema类型
    \d

   3. 根据schema授权
    grant all privileges on all tables in schema public to chat;
    
    grant usage,select on all sequences in shcema public to chat;

转载于:https://www.cnblogs.com/zhaojonjon/p/6912361.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值