cassandra用户名和密码的设置

  设置Cassandra使用用户名和密码验证的步骤如下:
  1.修改${CASSANDRA_HOME}/conf/cassandra.yaml,把authenticator: AllowAllAuthenticator修改为authenticator: PasswordAuthenticator

  2.使用默认的用户名cassandra和密码cassandra登录cassandra数据库,创建新的用户名和密码

CREATE USER myusername WITH PASSWORD 'mypassword' SUPERUSER ;

  3.使用新的用户名和密码登录,删除morning的用户cassandra

DROP USER cassandra ;

  4.使用java代码链接数据库的代码如下:

public static void connect(){
        cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9042).withCredentials("root","root").build();
        session = cluster.connect();
    }

 

posted @ 2017-12-25 10:54  木易森林  阅读(3946)  评论(0编辑  收藏  举报