Connect to DSE with the CQL shell (cqlsh)
The CQL shell (cqlsh) is a Python-based command-line shell you can use to issue Cassandra Query Language (CQL) statements to your DataStax Enterprise (DSE) databases.
The CQL shell also provides unique cqlsh commands like DESCRIBE KEYSPACE.
Start the CQL shell and connect to a node
Start cqlsh from the directory where it is installed.
For example, for the tarball-bundled CQL shell, run cqlsh from the bin directory of your DSE installation:
bin/cqlsh
Starting cqlsh with no arguments attempts to connect to the local node without authentication.
To connect to a remote node, provide the IP address of the target node:
bin/cqlsh IP_ADDRESS
If the node requires authentication, provide the required credentials. The following example uses internal username and password authentication. For other options, like Kerberos authentication and SSL encryption, see Use a cqlshrc file.
bin/cqlsh IP_ADDRESS -u DATABASE_ROLE_NAME -p DATABASE_ROLE_PASSWORD
|
Credentials passed on the command line can be stored in your shell history.
To avoid this, pass only the |
Use a cqlshrc file
As an alternative to command line arguments, you can store these values in a cqlshrc file that cqlsh reads automatically at startup.
For more information, see Use a cqlshrc file.
Run commands with the CQL shell
A successful connection shows the connection details and the cqlsh prompt:
Connected to Test Cluster at 127.0.0.1:9042
Connected to dse-6.9.0-cluster at 127.0.0.1:9042.
[cqlsh 6.8.0 | DSE 6.9.0 | CQL spec 3.4.5 | DSE protocol v2]
Use HELP for help.
cqlsh>
At the cqlsh prompt, issue CQL or cqlsh commands.
Troubleshoot the CQL shell
If cqlsh cannot connect, and it mentions a different port than 9042, make sure your ~/.cassandra/cqlshrc file isn’t modifying the default port.
For command help, run cqlsh --help.
For detailed logs, start cqlsh or run any cqlsh command with the --debug option.