Start cqlsh

The CQL shell (cqlsh) is a Python-based command line interface for running CQL commands interactively with support for tab completion.

cqlsh requires Python 2.7 or Python 3.6 through 3.11.

Start the standalone cqlsh for Cassandra

  1. See cqlsh: the CQL shell for details about cqlsh.

  2. Change to the directory where the tarball was extracted.

  3. Start the cqlsh script, specifying the location (such as /usr/bin) and other options as necessary.

    • Start with default options and no authentication:

      cqlsh
    • Connect to a specific node or use authentication:

      cqlsh host_name port -u username -p password

      Replace the following:

    • username and password: If authentication is enabled, provide a valid user and password for your cluster. For SSL-enabled clusters, see Providing Kerberos Credentials when Starting CQL Shell.

    • host_name and port: To connect to a non-default node or a remote database, provide the IP address or hostname of a node in the cluster, such as 10.100.176.166, and the CQL port number, such as 9042.

      cqlsh connects to 127.0.0.1 9042 by default. To connect to a different node or remote database, you can either set the $CQLSH_HOST and $CQLSH_PORT environment variables or specify the host and port on the command line, such as cqlsh host_name port. When a host and port number are given on the command line, they take precedence over any defaults.

  4. Print the help menu for cqlsh:

    cqlsh --help

Use cqlshrc for authentication

You can use a cqlshrc file to set default credentials when launching cqlsh. For more information about the cqlshrc file, see Configuring a cqlshrc file.

  1. Create a file named cqlshrc or modify an existing one.

  2. Specify a role name and password or other authentication parameters, depending on your cluster configuration.

    [authentication]
    username = name
    password = password123
  3. Save the file in home/.cassandra directory or your cqlsh installation directory.

  4. Set permissions on the file to prevent unauthorized access if the password is stored in plain text. If you are using cqlsh in a production environment, use secure references for passwords. The file must be readable by the user that starts cassandra.

    chmod 440 'home/.cassandra/cqlshrc'
  5. Check the permissions on home/.cassandra/cqlshrc_history to ensure that plain text passwords are not compromised.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax, an IBM Company | Privacy policy | Terms of use | Manage Privacy Choices

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