如何设置cassandra用户名和密码

适应于cassandra2.0以上的版本

1、首先修改配置文件 cassandra.yaml

把默认的authenticator: AllowAllAuthenticator运行所有人登录设置为用密码登录:

authenticator: PasswordAuthenticator

2、登录cassandra创建用户

使用默认账户登录cassandra

在bin目录下执行

./cqlsh -ucassandra -pcassandra

创建用户

CREATE USER myusername WITH PASSWORD 'mypassword' SUPERUSER ;

 3、使用新用户登录

删除默认帐号:

DROP USER cassandra ;

 4、java使用用户名密码访问cassandra

Cluster cluster = Cluster.builder()
.addContactPoint("192.168.22.161")
.withCredentials("myusername", "mypassword")
.build();

 

猜你喜欢

转载自longzhun.iteye.com/blog/2343389