All Products
Search
Document Center

ApsaraDB for ClickHouse:Use the CLI of ApsaraDB for ClickHouse to connect to a cluster

Last Updated:May 24, 2023

This topic describes how to use the CLI of ApsaraDB for ClickHouse to connect to an ApsaraDB for ClickHouse cluster.

Prerequisites

  • An ApsaraDB for ClickHouse cluster is created. For more information, see Create an ApsaraDB for ClickHouse cluster.

  • The username and the password of a database account are created. For more information, see Create an account.

  • The clickhouse-client tool that corresponds to the version of the ApsaraDB for ClickHouse cluster is installed. For more information about the download link, see clickhouse-client.

  • If a server where the clickhouse-client tool is installed is not deployed in the same virtual private cloud (VPC) as the ApsaraDB for ClickHouse cluster, apply for a public endpoint for the ApsaraDB for ClickHouse cluster. For more information, see Apply for and release a public endpoint.

  • The IP address of the server where the clickhouse-client tool is installed is added to the whitelist of the ApsaraDB for ClickHouse cluster. For more information, see Configure a whitelist.

Procedure

  1. Log on to the server where the clickhouse-client tool is installed.

  2. Run the following command to connect to the ApsaraDB for ClickHouse cluster. You can use the following syntax:

    clickhouse-client --host=<host> --port=<port> --user=<user> --password=<password>; 

    The following table describes the parameters.

    Parameter

    Description

    host

    The public endpoint for connections over the Internet or internal endpoint for connections over VPCs.

    On the Cluster Information page, view the public endpoint for connections over the Internet or internal endpoint for connections over VPCs.

    Note

    If the server where the clickhouse-client tool is installed is deployed in the same VPC as the ApsaraDB for ClickHouse cluster, we recommend that you use the internal endpoint for connections over VPCs to connect to the cluster. If the server where the clickhouse-client tool is installed is not deployed in the same VPC as the ApsaraDB for ClickHouse cluster, we recommend that you use the public endpoint for connections over the Internet to connect to the cluster.

    port

    The TCP port number.

    On the Cluster Information page, view the TCP port number.

    user

    The username of the database account.

    password

    The password of the database account.