cqlsh) to connect to Cassandra databases created using the DataStax Astra console.
- Download and install DataStax Enterprise (DSE) or DataStax Distribution of Apache Cassandra (DDAC). You can run
cqlshcommands from a local or remote instance of either product.
- Create a Cassandra database or have a team member provide access to their Cassandra database to obtain database connection details.
- Download the secure connect bundle to obtain connection credentials for your database.
- On the machine where you installed either DSE or DDAC, create a ~/.cassandra directory in your home directory.
mkdir ~/.cassandraImportant: Make sure to include the period in the directory name.
- Copy the secure connect bundle that you downloaded and place it in the ~/.cassandra directory.
cp secure-connect-database_name.zip ~/.cassandra
- Unzip the secure connect bundle in the ~/.cassandra directory.
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.
- From the ~/.cassandra directory, connect to your database using
cqlsh -u database_user -p database_password
- User name for the database.
- Password for the specified user name.
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. database_user_name@cqlsh:keyspace_name>
Configuring the cqlshrc file
The cqlshrc file included in the secure connect bundle is preconfigured to work with your Cassandra database. However, if you want to modify that file to connect to other databases, use the following example as guidance.
[ssl] section of the cqlshrc file in your ~/.cassandra directory to include the path to your connection credentials.
username = username
password = password
[connection] hostname = database_endpoint port = port_number ssl = true [ssl] validate = true certfile = ~/.cassandra/certificate.crt userkey = ~/.cassandra/private_RSA_key usercert = ~/.cassandra/user_SSL_certificate
port_numberare 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.