This topic describes how to use the ClickHouse command line interface to connect to an ApsaraDB for ClickHouse cluster.
Prerequisites
You have created an ApsaraDB for ClickHouse cluster. For more information, see Create a cluster.
You have created a database account and password. For more information, see Create an account.
Install the clickhouse-client tool that matches the version of your ApsaraDB for ClickHouse cluster. To download the tool, see clickhouse-client.
If the server where the clickhouse-client is installed is not in the same VPC as the ApsaraDB for ClickHouse cluster, you must request a public endpoint for the ApsaraDB for ClickHouse cluster. For more information, see Request and release public endpoints.
The IP address of the server where the clickhouse-client is installed has been added to the whitelist of ApsaraDB for ClickHouse. For more information, see Set a whitelist.
Procedure
Log on to the server where clickhouse-client is installed.
Execute the connection command to connect to the ApsaraDB for ClickHouse cluster. The syntax is as follows.
clickhouse-client --host=<host> --port=<port> --user=<user> --password=<password>The following table describes the parameters.
Parameter
Description
hostThe public endpoint or VPC endpoint. You can view the public endpoint or VPC endpoint on the Cluster Information page.
NoteIf the server that hosts clickhouse-client is in the same VPC as the ApsaraDB for ClickHouse cluster, we recommend that you use the VPC address to connect. If they are not in the same VPC, we recommend that you use the public endpoint to connect.
portThe TCP port number. You can view the TCP port number on the Cluster Information page.
userThe database account.
passwordThe password of the database account.