postgres赋予角色登录权限
来源:互联网 发布:淘宝男士休闲鞋 编辑:程序博客网 时间:2024/06/10 03:53
创建的role默认没有登录数据库的权限:
highgo=# create role a with password 'aaa';
CREATE ROLE
highgo=# \c highgo a
致命错误: 不允许角色"a" 进行登录
需要单独赋予角色login权限:
highgo=# alter role a login;
ALTER ROLE
highgo=# \c highgo a
You are now connected to database "highgo" as user "a".
highgo=>
直接创建的user可以登录数据库:
highgo=# create user b with password 'bbb';
CREATE ROLE
highgo=# \c highgo b
You are now connected to database "highgo" as user "b".
highgo=>
*****************************************************************
将角色赋予login权限后,可以连接登录所有的数据库:
highgo=# alter role a login;
ALTER ROLE
highgo=# \c highgo a
You are now connected to database "highgo" as user "a".
highgo=> \c template1 a
You are now connected to database "template1" as user "a".
template1=> \c
You are now connected to database "template1" as user "a".
template1=> \c highgo highgo
You are now connected to database "highgo" as user "highgo".
回收角色的login权限后,赋予连接某一个数据库的权限后也无法连接数据库:
highgo=# alter role a nologin;
ALTER ROLE
highgo=# grant connect on database template1 to a;
GRANT
highgo=# \c template1 a
致命错误: 不允许角色"a" 进行登录
Previous connection kept
*************************************************************************
highgo=# \c benchmarksql b
致命错误: 不允许角色"b" 进行登录
Previous connection kept
highgo=# grant connect on database benchmarksql to b;
GRANT
highgo=# \c benchmarksql b
致命错误: 不允许角色"b" 进行登录
Previous connection kept
highgo=# alter role b login;
ALTER ROLE
highgo=# \c benchmarksql b
You are now connected to database "benchmarksql" as user "b".
benchmarksql=> \c highgo highgo
You are now connected to database "highgo" as user "highgo".
highgo=# drop role b;
错误: 无法删除"b"因为有其它对象倚赖它
DETAIL: 数据库 benchmarksql的权限
highgo=# drop role b cascade;
错误: 语法错误 在 "cascade" 或附近的
LINE 1: drop role b cascade;
^
highgo=# revoke connect on database benchmarksql from b;
REVOKE
highgo=# drop role b ;
DROP ROLE
highgo=# create role a with password 'aaa';
CREATE ROLE
highgo=# \c highgo a
致命错误: 不允许角色"a" 进行登录
需要单独赋予角色login权限:
highgo=# alter role a login;
ALTER ROLE
highgo=# \c highgo a
You are now connected to database "highgo" as user "a".
highgo=>
直接创建的user可以登录数据库:
highgo=# create user b with password 'bbb';
CREATE ROLE
highgo=# \c highgo b
You are now connected to database "highgo" as user "b".
highgo=>
*****************************************************************
将角色赋予login权限后,可以连接登录所有的数据库:
highgo=# alter role a login;
ALTER ROLE
highgo=# \c highgo a
You are now connected to database "highgo" as user "a".
highgo=> \c template1 a
You are now connected to database "template1" as user "a".
template1=> \c
You are now connected to database "template1" as user "a".
template1=> \c highgo highgo
You are now connected to database "highgo" as user "highgo".
回收角色的login权限后,赋予连接某一个数据库的权限后也无法连接数据库:
highgo=# alter role a nologin;
ALTER ROLE
highgo=# grant connect on database template1 to a;
GRANT
highgo=# \c template1 a
致命错误: 不允许角色"a" 进行登录
Previous connection kept
*************************************************************************
highgo=# \c benchmarksql b
致命错误: 不允许角色"b" 进行登录
Previous connection kept
highgo=# grant connect on database benchmarksql to b;
GRANT
highgo=# \c benchmarksql b
致命错误: 不允许角色"b" 进行登录
Previous connection kept
highgo=# alter role b login;
ALTER ROLE
highgo=# \c benchmarksql b
You are now connected to database "benchmarksql" as user "b".
benchmarksql=> \c highgo highgo
You are now connected to database "highgo" as user "highgo".
highgo=# drop role b;
错误: 无法删除"b"因为有其它对象倚赖它
DETAIL: 数据库 benchmarksql的权限
highgo=# drop role b cascade;
错误: 语法错误 在 "cascade" 或附近的
LINE 1: drop role b cascade;
^
highgo=# revoke connect on database benchmarksql from b;
REVOKE
highgo=# drop role b ;
DROP ROLE
阅读全文
0 0
- postgres赋予角色登录权限
- ubuntu11.04下POSTGRES SQL 创建角色,赋予角色访问数据库权限及sqlalchmey的database_url配置
- MSDE 增加登录用户名及赋予角色
- 登录Oracle 并建立用户,赋予权限
- mySql远程登录的用户赋予权限
- 赋予用户权限和角色后 权限何时生效
- oracle创建用户并赋予sys角色权限
- 创建oracle用户并赋予dba角色的权限
- linux给角色赋予操作文件的权限
- 登录名、用户、角色、权限
- Oracle之 赋予resource角色自动赋予UNLIMITED TABLESPACE权限,回收同理。
- 权限赋予
- 赋予权限
- 使用T-SQL脚本在SQL Server创建角色,并给角色赋予相应权限
- Drupal上使用代码添加新角色,并赋予角色权限
- Oracle用户、权限、角色管理与登录
- 给flexviewer登录窗口(角色 权限)
- 角色权限管理系统(登录模块)
- 面临大鱼号新政策如何开通收益
- Kotlin总结2
- Vuex架构设计
- sql server2008 活动监视器
- Elasticsearch 5.6.1版本体验
- postgres赋予角色登录权限
- Android Volley架构分析
- 交叉表实现PIVOT方式
- 无法覆盖bootstrap的样式
- mysql 主从复制原理
- RAR和ZIP:压缩大战真相
- 个人收藏的工具函数--持续更新(ts语言)
- 求3+33+333+3333+33333......的值
- 文章用图的修改和排版 (一)