转自:http://zhaoyanblog.com/archives/307.html
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();