Connect to HCD 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 Hyper-Converged Database (HCD) databases.
The CQL shell also provides unique cqlsh commands like DESCRIBE KEYSPACE.
These steps are for running the CQL shell on the command line. If you are using the embedded CQL shell in Mission Control, see Use the CQL console to interact with the databases in your datacenter.
Start the CQL shell
To start the CQL shell, run cqlsh directly on the command line if it is in your system’s PATH.
Otherwise, run bin/cqlsh from the directory where you installed HCD or a standalone cqlsh binary (without HCD).
For example:
# In PATH
cqlsh
# Not in PATH
INSTALL_DIRECTORY/bin/cqlsh
Connect to a node
Starting cqlsh with no arguments attempts to connect to the local node without authentication if no credentials are provided in a cqlshrc file.
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 LDAP 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 hcd-cluster at 192.0.2.200:9042
[cqlsh 6.1.0 | Cassandra 4.1.x | CQL spec 3.4.6 | Native protocol v5]
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.