> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# cockroach Commands Overview

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

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

| Command                                                                                                               | Usage                                                                                                                                                  |
| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <InternalLink path="cockroach-start">`cockroach start`</InternalLink>                                                 | Start a node as part of a multi-node cluster.                                                                                                          |
| <InternalLink path="cockroach-init">`cockroach init`</InternalLink>                                                   | Initialize a multi-node cluster.                                                                                                                       |
| <InternalLink path="cockroach-start-single-node">`cockroach start-single-node`</InternalLink>                         | Start a single-node cluster.                                                                                                                           |
| <InternalLink path="cockroach-cert">`cockroach cert`</InternalLink>                                                   | Create CA, node, and client certificates.                                                                                                              |
| <InternalLink path="cockroach-sql">`cockroach sql`</InternalLink>                                                     | Use the built-in SQL client.                                                                                                                           |
| <InternalLink path="cockroach-sqlfmt">`cockroach sqlfmt`</InternalLink>                                               | Reformat SQL queries for enhanced clarity.                                                                                                             |
| <InternalLink path="cockroach-node">`cockroach node`</InternalLink>                                                   | List node IDs, show their status, decommission nodes for removal, or recommission nodes.                                                               |
| <InternalLink path="cockroach-nodelocal-upload">`cockroach nodelocal upload`</InternalLink>                           | Upload a file to the `externalIODir` on a node's local file system.                                                                                    |
| <InternalLink path="cockroach-auth-session">`cockroach auth-session`</InternalLink>                                   | Create and manage web sessions and authentication tokens to the HTTP interface from the command line.                                                  |
| <InternalLink path="cockroach-demo">`cockroach demo`</InternalLink>                                                   | Start a temporary, in-memory CockroachDB cluster, and open an interactive SQL shell to it.                                                             |
| <InternalLink path="cockroach-debug-ballast">`cockroach debug ballast`</InternalLink>                                 | Create a large, unused file in a node's storage directory that you can delete if the node runs out of disk space.                                      |
| <InternalLink path="cockroach-debug-encryption-active-key">`cockroach debug encryption-active-key`</InternalLink>     | View the encryption algorithm and store key.                                                                                                           |
| <InternalLink path="cockroach-debug-job-trace">`cockroach debug job-trace`</InternalLink>                             | Generate trace payloads for an executing job from a particular node.                                                                                   |
| <InternalLink path="cockroach-debug-list-files">`cockroach debug list-files`</InternalLink>                           | Show the files that will be collected by using `cockroach debug zip`.                                                                                  |
| <InternalLink path="cockroach-debug-merge-logs">`cockroach debug merge-logs`</InternalLink>                           | 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. |
| <InternalLink path="cockroach-debug-pebble-db-analyze-data">`cockroach debug pebble db analyze-data`</InternalLink>   | Analyze Pebble data to compare compression algorithms and output results as a CSV file.                                                                |
| <InternalLink path="cockroach-debug-tsdump">`cockroach debug tsdump`</InternalLink>                                   | Generate a diagnostic dump of timeseries metrics that can help Cockroach Labs troubleshoot issues with your cluster.                                   |
| <InternalLink path="cockroach-debug-zip">`cockroach debug zip`</InternalLink>                                         | Generate a `.zip` file that can help Cockroach Labs troubleshoot issues with your cluster.                                                             |
| <InternalLink path="connection-parameters#convert-a-url-for-different-drivers">`cockroach convert-url`</InternalLink> | Convert a connection URL to a format recognized by a <InternalLink path="third-party-database-tools#drivers">supported client driver</InternalLink>.   |
| <InternalLink path="cockroach-gen">`cockroach gen`</InternalLink>                                                     | Generate man pages, a bash completion file, example SQL data, or an HAProxy configuration file for a running cluster.                                  |
| <InternalLink path="cockroach-statement-diag">`cockroach statement-diag`</InternalLink>                               | Manage and download statement diagnostics bundles.                                                                                                     |
| <InternalLink path="cockroach-userfile-upload">`cockroach userfile upload`</InternalLink>                             | Upload a file to user-scoped file storage.                                                                                                             |
| <InternalLink path="cockroach-userfile-list">`cockroach userfile list`</InternalLink>                                 | List the files stored in the user-scoped file storage.                                                                                                 |
| <InternalLink path="cockroach-userfile-get">`cockroach userfile get`</InternalLink>                                   | Fetch a file from the user-scoped file storage.                                                                                                        |
| <InternalLink path="cockroach-userfile-delete">`cockroach userfile delete`</InternalLink>                             | Delete the files stored in the user-scoped file storage.                                                                                               |
| <InternalLink path="cockroach-version">`cockroach version`</InternalLink>                                             | Output CockroachDB version details.                                                                                                                    |
| <InternalLink path="cockroach-workload">`cockroach workload`</InternalLink>                                           | 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](#commands).
* To output the current configuration of CockroachDB and other environment variables, run `env`.
* When a node uses environment variables on <InternalLink path="cockroach-start">startup</InternalLink>, 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 <InternalLink path="connection-parameters">Client Connection Parameters</InternalLink>.
