cassandra

Learn how to install and connect to Cassandra using cqlsh. This cheatsheet covers client installation on Alpine Linux and network connection methods.

Cassandra Cheatsheet

Cassandra Client Guide

Installing cqlsh

This section details how to install the cqlsh client, a crucial tool for interacting with Cassandra databases. For users on Alpine Linux, the following commands will set up the necessary Python environment and install cqlsh.

To install the cqlsh client on alpine linux:

apk --no-cache add python3 py3-pip
pip3 install cqlsh

Connecting to Cassandra

Establishing a connection to your Cassandra cluster is straightforward using cqlsh. Below are the methods for connecting from the same node where cqlsh is installed, and for connecting over a network to a remote Cassandra instance.

From the same node:

cqlsh -u user -p password

Over the network:

CQLSH_HOST=cassandra.databases CQLSH_PORT=9042 cqlsh -u user -p password

Describing Keyspaces

To understand the structure of your Cassandra database, you can list all available keyspaces. This command is fundamental for database exploration and management.

DESCRIBE keyspaces;

For more in-depth information on Cassandra and its command-line interface, refer to the official Cassandra documentation and the cqlsh reference.