Use clickhouse-client to connect to an ApsaraDB for ClickHouse cluster from your local machine or server.
Prerequisites
Before you begin, ensure that you have:
-
An ApsaraDB for ClickHouse cluster. See Create a cluster
-
A database account and password. See Create an account
-
clickhouse-client installed, matching the version of your cluster. Download from clickhouse.com/docs/install
-
(If connecting from outside the cluster's Virtual Private Cloud (VPC)) A public endpoint for the cluster. See Request and release public endpoints
-
The IP address of the machine running clickhouse-client added to the cluster whitelist. See Set a whitelist
Connect to a cluster
-
Log in to the server where clickhouse-client is installed.
-
Run the following command to connect to the cluster:
clickhouse-client --host=<host> --port=<port> --user=<user> --password=<password>Replace the placeholders with the appropriate values:
Parameter Description hostThe endpoint of the cluster. Use the VPC endpoint if the client is in the same VPC as the cluster; use the public endpoint if not. You can view the endpoint on the Cluster Information page. portThe TCP port number. You can view the TCP port number on the Cluster Information page. userThe database account. passwordThe password for the database account. -
Verify that the connection succeeded. A successful connection displays output similar to the following:
ClickHouse client version <version> (official build). Connecting to <host>:<port> as user <user>. Connected to ClickHouse server version <version>. :)The
:)prompt indicates the connection is active and ready to accept queries.