Windows usersClickHouse runs natively on Linux and macOS. On Windows, run these steps inside
the Windows Subsystem for Linux (WSL).
clickhousectl, alias chctl) installs and manages local
ClickHouse versions, runs local ClickHouse and Postgres servers, runs queries,
and manages ClickHouse Cloud. This page walks you through installing the CLI,
starting a local ClickHouse server, and connecting to it.
If you used the quick install
script, clickhousectl is already installed. Skip to
Install ClickHouse.
1
Install the ClickHouse CLI
The install script supports macOS and Linux on x86_64 and ARM64:The script installs
To check for a newer CLI release, and to install it:
clickhousectl to ~/.local/bin and creates a chctl
alias next to it. If the script says ~/.local/bin is not on your PATH, add it,
and add the same line to your shell profile (~/.bashrc, ~/.zshrc) for future
sessions:Other installation methods
Other installation methods
Only the install script and npm create the
chctl alias.2
Install ClickHouse
Install the latest version of ClickHouse and make it your default:To see which minor versions are available to download, and which versions you
have installed:
local use installs the version if it isn’t already present, sets it as your
default, and creates a clickhouse symlink in ~/.local/bin, so you can run the
clickhouse binary directly. Any later step in these docs that runs a
clickhouse command then works as-is, provided ~/.local/bin is on your PATH.You can also select the latest long-term support release, or a specific
version:Use vs install
clickhousectl local use <version> installs a version and makes it your
default, updating the clickhouse symlink. clickhousectl local install <version>
only downloads a version; it becomes your default only if you have no default
yet, and it doesn’t update the symlink. To set the default without creating or
updating the symlink, use clickhousectl local use <version> --no-global.3
Start clickhouse-server
clickhousectl scopes local servers to the directory you run it from. Create a
project directory and start a server there:default. Its data lives in
./.clickhouse/, so run later clickhousectl local commands from the same
directory; clickhousectl doesn’t search parent directories. The server listens
on HTTP port 8123 and TCP port 9000, or on free ports when those are taken.
To choose the ports, pass --http-port and --tcp-port. To run more than one
server, give each a name, such as clickhousectl local server start dev.To verify it’s running:4
Start clickhouse-client
Connect to the server with You’re now ready to start sending SQL commands to ClickHouse! Type
clickhouse-client, from the same directory:local client connects to the server named default and uses the same
ClickHouse version as the server. Pass a name to connect to another server,
such as clickhousectl local client dev. You will see something like this:exit to
leave the client.To run a single query without opening an interactive session, pass -q:5
Stop the server
The server keeps running in the background until you stop it. Stop it from the
same directory:Stopping preserves the server’s data for the next
clickhousectl local server start.Next steps
-
Run Postgres locally. With Docker running, start a local Postgres server
and connect to it with
psql: -
Connect to ClickHouse Cloud. Create an account, or log in to an existing
one. Browser login is read-only; creating or changing Cloud resources needs an
API key, which
clickhousectl cloud auth login --interactiveprompts for. -
Learn the rest of the CLI. See the clickhousectl reference,
or run
clickhousectl --help.