Skip to content
Latchkey

clickhouse-client: Usage, Options & Common CI Errors

clickhouse-client runs SQL against a ClickHouse server from the shell.

clickhouse-client seeds tables and runs assertions against a ClickHouse service in CI. The recurring failures are the native-vs-HTTP port, authentication, and FORMAT-driven output parsing.

What it does

clickhouse-client connects to a ClickHouse server over the native protocol (port 9000) and runs SQL interactively, from --query, or from piped input. Output format is controlled by a FORMAT clause, which matters when shell scripts parse results.

Common usage

Terminal
clickhouse-client --host localhost --query 'SELECT version()'
clickhouse-client --host localhost --user default --password secret --query 'SELECT 1'
clickhouse-client --host db --multiquery < schema.sql
clickhouse-client --host localhost --query 'SELECT count() FROM t FORMAT TSV'

Options

FlagWhat it does
--host / --portServer host / native port (default 9000)
--user / --passwordCredentials
--database / -dDefault database
--query "SQL"Run one query and exit
--multiquery / -nAllow multiple ; -separated statements
FORMAT <name>Output format (TSV, CSV, JSON, Pretty)

Common errors in CI

Code: 516. DB::Exception: ... Authentication failed: password is incorrect - wrong --user/--password. "Code: 210. DB::NetException: Connection refused (localhost:9000)" means the server is not up or you used the HTTP port 8123 instead of the native 9000. "Code: 62 ... Syntax error" on a multi-statement file means you forgot --multiquery. Default Pretty output has box drawing; add FORMAT TSV (or TSVRaw) when capturing a value in a shell variable.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →