Using tab completion
You can use tab completion to see hints about how to complete a cqlsh command. Some platforms, such as Mac OSX, do not ship with tab completion installed. You can use easy_install to install tab completion capabilities on Mac OSX:
pip install readline
List keyspace
show all current key spaces.
SELECT * FROM system_schema.keyspaces ;
Set password authenticator
- modify
config/cassandra.yaml
, change AllowAllAuthenticator to PasswordAuthenticator.
# authenticator: AllowAllAuthenticator -> PasswordAuthenticator
authenticator: PasswordAuthenticator
- login default user: cassandra, password: cassandra
[root@megvii-redhat] ~/apache-cassandra-3.10
❯ cqlsh -u cassandra -p cassandra ⏎
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh>
- create a new user's account.
cassandra@cqlsh> create USER megvii WITH PASSWORD 'megvii' SUPERUSER ;
cassandra@cqlsh> exit
[root@megvii-redhat] ~/apache-cassandra-3.10
❯
- login with new user, and remove default user.
[root@megvii-redhat] ~/apache-cassandra-3.10
❯ cqlsh -u megvii -p megvii ⏎
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
megvii@cqlsh> DROP USER cassandra ;
megvii@cqlsh> exit
网友评论