扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
Cassandra用role代替用户和用户组,默认创建的role没有login和super权限;
成都创新互联2013年开创至今,先为东乌珠穆沁等服务建站,东乌珠穆沁等地企业,进行企业商务咨询服务。为东乌珠穆沁企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。
但是默认创建的user是有login的权限
(1)角色
#创建角色
cassandra@cqlsh:keyspace1> create role cdhu1;
cassandra@cqlsh:keyspace1> create role cdhu2 with password='147258' and login=true;
cassandra@cqlsh:keyspace1> create role cdhu3 with password='147258' and login=true and superuser=true;
#查看角色
cassandra@cqlsh:keyspace1> list roles;
role | super | login | options
-----------+-------+-------+---------
cassandra | True | True | {}
cdhu1 | False | False | {}
cdhu2 | False | True | {}
cdhu3 | True | True | {}
cassandra@cqlsh:keyspace1> list roles of cdhu3;
role | super | login | options
-------+-------+-------+---------
cdhu3 | True | True | {}
#修改角色cdhu3的属性
cassandra@cqlsh:keyspace1> ALTER ROLE cdhu3 WITH PASSWORD = '147258' AND SUPERUSER = false;
#把角色cdhu3的权限赋予传递给角色cdhu2:
cassandra@cqlsh:keyspace1> grant cdhu3 to cdhu2;
cassandra@cqlsh:keyspace1> revoke cdhu3 from cdhu2;
(2)用户
cassandra@cqlsh:keyspace1> create user user1 with password '147258' superuser;
cassandra@cqlsh:keyspace1> create user user2 with password '147258' nosuperuser;
cassandra@cqlsh:keyspace1> list users;
name | super
-----------+-------
cassandra | True
user1 | True
user2 | False
(3)权限
CREATE
ALTER
DROP
SELECT
MODIFY
AUTHORIZE
DESCRIBE
EXECUTE
#grant&revoke
cassandra@cqlsh:keyspace1> grant select on keyspace1.t1 to cdhu2;
cassandra@cqlsh:keyspace1> grant modify on keyspace keyspace1 to cdhu2;
cassandra@cqlsh:keyspace1> revoke select on kyepsace1.t1 from cdhu2
#查看角色或用户的权限
cassandra@cqlsh:keyspace1> list all permissions;
cassandra@cqlsh:keyspace1> list all permissions of cdhu2;
role | username | resource | permission
-------+----------+----------------------+------------
cdhu2 | cdhu2 |
cdhu2 | cdhu2 |