Connecting to databases using the native CQLSH

Configure CQLSH to log in to an Astra database and run CQL commands.

Use the Cassandra Query Language SHell (CQLSH) that is native to DataStax Enterprise (DSE) or DataStax Distribution of Apache Cassandra™ (DDAC) to connect to DataStax Astra databases created using the DataStax Cloud console.
Tip: Alternatively, connect to your database using DataStax Studio, which is automatically configured for interactive CQL commands. Use the predefined notebooks to learn CQL basics and start creating tables in your keyspace.

You can also use the embedded CQLSH or standalone CQLSH, which is a standalone tool for interacting with your database using CQL commands.


  1. Download and install CQLSH. Choose the CQLSH version for the latest DSE version.
  2. Create a DataStax Astra database.
  3. Download the secure connect bundle to obtain connection credentials for your DataStax Astra database.


  1. On the machine where you downloaded CQLSH, create a ~/.cassandra directory in your home directory.
    mkdir ~/.cassandra
    Important: Make sure to include the period in the directory name.
  2. Copy the secure connect bundle that you downloaded and place it in the ~/.cassandra directory.
    cp ~/.cassandra
  3. Unzip the secure connect bundle in the ~/.cassandra directory.
    cd ~/.cassandra

    The cqlshrc file is included in the secure connect bundle. When you unzip the bundle, this file will be placed in your ~/.cassandra directory.

    Note: Only one cqlshrc file is supported per directory. The default directory for this file is ~/.cassandra.
    User name for the database.
    Password for the specified username.
  4. From the ~/.cassandra directory, connect to your database using CQLSH.
    cqlsh -u database_user -p database_password
    User name for the database.
    Password for the specified username.
    Connected to database_name at host_name:30003.
    [cqlsh 5.0.1 | DSE 6.8.0 | CQL spec 3.4.5 | DSE protocol v2]
    Use HELP for help.


You can now connect directly to the database using cqlsh.

Configuring the cqlshrc file

The cqlshrc file included in the secure connect bundle is preconfigured to work with your Astra database. However, if you want to modify that file to connect to other databases, use the following example as guidance.

Configure the [ssl] section of the cqlshrc file in your ~/.cassandra directory to include the path to your connection credentials.

hostname = database_endpoint
port = port_number
ssl = true

validate = true
certfile = ~/.cassandra/certificate.crt
userkey  = ~/.cassandra/private_RSA_key
usercert = ~/.cassandra/user_SSL_certificate

The following information is copied from the database Connection Details page in the DataStax Cloud console. Values for the database_endpoint and port_number are written to the cqlshrc file when you download database credentials.
Endpoint for the database, such as
Port number on the database used to connect to DSE.
Location of the security certificate for the database, which uses a .crt extension.
Private RSA key for connecting to the indicated database.
SSL certificate for the indicated user.

What's next

See the following documentation to get started with CQL: