Skip to main content
This page introduces the cockroach commands for configuring, starting, and managing a CockroachDB cluster, as well as environment variables that can be used in place of certain flags. You can run cockroach help in your shell to get similar guidance.

Commands

CommandUsage
Start a node as part of a multi-node cluster.
Initialize a multi-node cluster.
Start a single-node cluster.
Create CA, node, and client certificates.
Use the built-in SQL client.
Reformat SQL queries for enhanced clarity.
List node IDs, show their status, decommission nodes for removal, or recommission nodes.
Upload a file to the externalIODir on a node’s local file system.
Create and manage web sessions and authentication tokens to the HTTP interface from the command line.
Start a temporary, in-memory CockroachDB cluster, and open an interactive SQL shell to it.
Create a large, unused file in a node’s storage directory that you can delete if the node runs out of disk space.
View the encryption algorithm and store key.
Generate trace payloads for an executing job from a particular node.
Show the files that will be collected by using cockroach debug zip.
Merge log files from multiple nodes into a single time-ordered stream of messages with an added per-message prefix to indicate the corresponding node.
Analyze Pebble data to compare compression algorithms and output results as a CSV file.
Generate a diagnostic dump of timeseries metrics that can help Cockroach Labs troubleshoot issues with your cluster.
Generate a .zip file that can help Cockroach Labs troubleshoot issues with your cluster.
Convert a connection URL to a format recognized by a .
Generate man pages, a bash completion file, example SQL data, or an HAProxy configuration file for a running cluster.
Manage and download statement diagnostics bundles.
Upload a file to user-scoped file storage.
List the files stored in the user-scoped file storage.
Fetch a file from the user-scoped file storage.
Delete the files stored in the user-scoped file storage.
Output CockroachDB version details.
Run a built-in load generator against a cluster.

Environment variables

For many common cockroach flags, such as --port and --user, you can set environment variables once instead of manually passing the flags each time you execute commands.
  • To find out which flags support environment variables, see the documentation for each command.
  • To output the current configuration of CockroachDB and other environment variables, run env.
  • When a node uses environment variables on , the variable names are printed to the node’s logs; however, the variable values are not.
CockroachDB prioritizes command flags, environment variables, and defaults as follows:
  1. If a flag is set for a command, CockroachDB uses it.
  2. If a flag is not set for a command, CockroachDB uses the corresponding environment variable.
  3. If neither the flag nor environment variable is set, CockroachDB uses the default for the flag.
  4. If there’s no flag default, CockroachDB gives an error.
For more details, see .