Connect to DSE with cqlsh
The main way that you interact with DataStax Enterprise (DSE) is through the CQL shell (cqlsh), a Python-based command-line shell for accessing the database and issuing Cassandra Query Language (CQL) commands.
Install cqlsh
There are three ways to get a DSE-compatible version of cqlsh.
All options require Python 3.6 or later.
-
Standalone installation
-
Tarball bundled installation
-
Docker bundled installation
To use a standalone cqlsh installation, download a DSE-compatible version of cqlsh from Fix Central.
-
Get access to Fix Central. You need the following:
-
An IBMid.
-
If you are an existing IBM customer with an IBMid, you can continue to use your established account.
-
If you don’t have an IBMid, you can create one.
-
If your company uses Enterprise Federation (EF) for authentication with corporate credentials, see the EF documentation.
-
-
-
Download
cqlshfrom Fix Central:-
Sign in to Fix Central.
-
In the Product selector field, enter
IBM DataStax Enterprise. -
Select the DSE version of the
cqlshtool you want to install from the Select from IBM DataStax Enterprise list. -
Select All in the Platform list, and then click Continue.
-
On the Identify fixes page, click Continue to use the default Browse for fixes option.
-
Select the fixes (DSE version of the
cqlshtool) you want to install, and then click Continue. -
Review the terms and conditions, and then click I agree.
-
-
Click the
cqlshbinary tarball link to download the file, for example,cqlsh-6.9.15-bin.tar.gz. -
Once the file is downloaded, change to the directory where you want to install
cqlsh, and then extract the distribution:tar -xzvf cqlsh-**VERSION**-bin.tar.gzReplace
VERSIONwith the package version that you downloaded, such as6.9.15.
If you have installed DSE from the tarball, you can find the cqlsh script in the bin directory of the DSE installation directory.
If you are using the DSE Docker container, you can run the cqlsh script inside the container in the bin directory of the DSE installation directory.
Run cqlsh
-
Change to the
/bindirectory of your DSE installation or the directory where you extracted thecqlshdistribution. -
Start
cqlshand connect to a local or remote node:-
Local node
-
Remote node
-
Connect to a local node without authentication:
bin/cqlsh -
Connect to a local node with authentication by providing the required username and password:
bin/cqlsh -u DATABASE_USERNAME -p DATABASE_PASSWORD
To connect to a remote node, you must specify the IP address of the node in the cluster that you want to connect to:
bin/cqlsh IP_ADDRESSIf authentication is required, include the username and password:
bin/cqlsh IP_ADDRESS -u DATABASE_USERNAME -p DATABASE_PASSWORDIf
cqlshstarts properly, version numbers and thecqlshprompt appear.Result
Connected to Test Cluster at 127.0.0.1:9042 Connected to dse-6.9.0-early-preview-cluster at 127.0.0.1:9042. [cqlsh 6.8.0 | DSE 6.9.0-early-preview | CQL spec 3.4.5 | DSE protocol v2] Use HELP for help. cqlsh>If
cqlshcannot connect and mentions a different port than 9042, check your~/.cassandra/cqlshrcfile, which could be modifying the defaults.For command help, run
bin/cqlsh --help. -
|
You can use a
For a complete list of options, see the cqlsh reference documentation. |