CQL for Apache Cassandra

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

  1. modify config/cassandra.yaml, change AllowAllAuthenticator to PasswordAuthenticator.
# authenticator:  AllowAllAuthenticator -> PasswordAuthenticator
authenticator: PasswordAuthenticator
  1. 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>
  1. 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
❯
  1. 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

你可能感兴趣的:(CQL for Apache Cassandra)