Use and configure the Cassandra Query Language (CQL) shell (cqlsh)

Objective

The main way that you interact with Hyper-Converged Database (HCD) is through the CQL shell (cqlsh), a Python-based command-line shell for accessing the database and issuing CQL (Cassandra Query Language) commands. This tutorial shows you how to configure and use cqlsh.

Prerequisites

Location and how to run cqlsh

The cqlsh command is located in the bin directory of the HCD installation. If you install the standalone cqlsh, the command is located in the bin directory where the download file is extracted, or unzipped.

Running cqlsh

To run cqlsh locally

No IP address is required when running cqlsh locally.

bin/cqlsh
Results
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.2.0 | Cassandra 5.0 | CQL spec 3.4.7 | Native protocol v5]
Use HELP for help.
cqlsh> 

To run cqlsh remotely

To run cqlsh, you’ll specify the IP address of a node in the cluster.

bin/cqlsh 10.0.0.1
Results
Connected to Test Cluster at 10.0.0.1:9042
[cqlsh 6.2.0 | Cassandra 5.0 | CQL spec 3.4.7 | Native protocol v5]
Use HELP for help.
cqlsh> 

To use a username and password

If you use security features, provide the username and password to authenticate with the database:

bin/cqlsh -u jane -p ScoobiePeanut&!

Get cqlsh help menu

bin/cqlsh --help

There are a number of options that can be used with cqlsh. For a complete list of options, see the cqlsh reference page.

Using the cqlshrc file for configuration

bin/cqlsh CQLSHRC="~/<directory_name>"

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com