Managing users
1. Edit the cassandra.yaml file as follows
sudo vim /etc/cassandra/cassandra/yaml
look for
authenticatoroption in the filedefault option is
authenticator: AllowAllAuthenticatorchange the above as follows
authenticator: PasswordAuthenticatorrestart cassandra
sudo service cassandra restart
2. Run the cqlsh as follows
general
cqlsh <node-server-ip-address> -u cassandra -p cassandra
eg
cqlsh 172.31.92.220 -u cassandra -p cassandra
log-data
hadoop@ip-172-31-92-220:~$ cqlsh 172.31.92.220 -u cassandra -p cassandra
Connected to 02-04-18-Admatic-Cluster at 172.31.92.220:9042.
[cqlsh 5.0.1 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh>
3. List all users
command
list users;
Output
hadoop@ip-172-31-92-220:~$ cqlsh 172.31.92.220 -u cassandra -p cassandra
Connected to 02-04-18-Admatic-Cluster at 172.31.92.220:9042.
[cqlsh 5.0.1 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh> list users;
name | super
-----------+-------
cassandra | True
(1 rows)
4. Adding a new user
general
create user <user-name> with password '<password>' [superuser]/[nosuperuser];
eg
create user sakethaux with passsword '3122' nosuperuser;
log-data
cassandra@cqlsh> create user sakethaux with password '3122' nosuperuser;
cassandra@cqlsh> list users;
name | super
-----------+-------
cassandra | True
sakethaux | False
(2 rows)
cassandra@cqlsh>
5. Alter user privileges
general
alter user <user-name> [superuser]/[nosuperuser];
eg
alter user sakethaux superuser;
log-data
cassandra@cqlsh> alter user sakethaux superuser;
cassandra@cqlsh> list users;
name | super
-----------+-------
cassandra | True
sakethaux | True
(2 rows)
cassandra@cqlsh>
6. Changing user's password
general
ALTER USER <user-name> WITH PASSWORD <'new-password'>;
eg
alter user sakethaux with password '312214104039'
7. Dropping a user
general
drop user if exists <user-name>;
eg
drop user if exists sakethaux;
log-data
cassandra@cqlsh> drop user if exists sakethaux;
cassandra@cqlsh> list users;
name | super
-----------+-------
cassandra | True
(1 rows)
cassandra@cqlsh>