ClickHouse Client

## Environment variable options[​](#environment-variable-options "Direct link to Environment variable options")

The user name, password and host can be set via environment variables `CLICKHOUSE_USER`, `CLICKHOUSE_PASSWORD` and `CLICKHOUSE_HOST`.
Command line arguments `--user`, `--password` or `--host`, or a [connection string](#connection_string) (if specified) take precedence over environment variables.

## Command-line options[​](#command-line-options "Direct link to Command-line options")

All command-line options can be specified directly on the command line or as defaults in the [configuration file](#configuration_files).

### General options[​](#command-line-options-general "Direct link to General options")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Option Description Default|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `-c [ -C, --config, --config-file ] <path-to-file>` The location of the configuration file for the client, if it is not at one of the default locations. See [Configuration Files](#configuration_files). -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--help` Print usage summary and exit. Combine with `--verbose` to display all possible options including query settings. -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--history_file <path-to-file>` Path to a file containing the command history. -|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--history_max_entries` Maximum number of entries in the history file. `1000000` (1 million)| `--prompt <prompt>` Specify a custom prompt. The `display_name` of the server| `--verbose` Increase output verbosity. -|  |  |  | | --- | --- | --- | | `-V [ --version ]` Print version and exit. - | | | | | | | | | | | | | | | | | | | | | | | |

### Connection options[​](#command-line-options-connection "Direct link to Connection options")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Option Description Default|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--connection <name>` The name of preconfigured connection details from the configuration file. See [Connection credentials](#connection-credentials). -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `-d [ --database ] <database>` Select the database to default to for this connection. The current database from the server settings (`default` by default)| `-h [ --host ] <host>` The hostname of the ClickHouse server to connect to. Can either be a hostname or an IPv4 or IPv6 address. Multiple hosts can be passed via multiple arguments. `localhost`| `--jwt <value>` Use JSON Web Token (JWT) for authentication.   Server JWT authorization is only available in ClickHouse Cloud. -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `login` Invokes the device grant OAuth flow in order to authenticate via an IDP.   For ClickHouse Cloud hosts, the OAuth variables are inferred otherwise they must be provided with `--oauth-url`, `--oauth-client-id` and `--oauth-audience`. -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--no-warnings` Disable showing warnings from `system.warnings` when the client connects to the server. -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--no-server-client-version-message` Suppress server-client version mismatch message when the client connects to the server. -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--password <password>` The password of the database user. You can also specify the password for a connection in the configuration file. If you do not specify the password, the client will ask for it. -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--port <port>` The port the server is accepting connections on. The default ports are 9440 (TLS) and 9000 (no TLS).   Note: The client uses the native protocol and not HTTP(S). `9440` if `--secure` is specified, `9000` otherwise. Always defaults to `9440` if the hostname ends in `.clickhouse.cloud`.| `-s [ --secure ]` Whether to use TLS.   Enabled automatically when connecting to port 9440 (the default secure port) or ClickHouse Cloud.   You might need to configure your CA certificates in the [configuration file](#configuration_files). The available configuration settings are the same as for [server-side TLS configuration](/docs/operations/server-configuration-parameters/settings#openssl). Auto-enabled when connecting to port 9440 or ClickHouse Cloud|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--ssh-key-file <path-to-file>` File containing the SSH private key for authenticate with the server. -|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--ssh-key-passphrase <value>` Passphrase for the SSH private key specified in `--ssh-key-file`. -|  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | | `--tls-sni-override <server name>` If using TLS, the server name (SNI) to pass in the handshake. The host provided via `-h` or `--host`.| `-u [ --user ] <username>` The database user to connect as. `default` | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |

Note

Instead of the `--host`, `--port`, `--user` and `--password` options, the client also supports [connection strings](#connection_string).

### Query options[​](#command-line-options-query "Direct link to Query options")