Connect to ClickHouse using the MySQL protocol
ApsaraDB for ClickHouse supports connections from MySQL clients. This topic describes how to connect to an ApsaraDB for ClickHouse cluster using the MySQL protocol.
Limits
Only ApsaraDB for ClickHouse Community-Compatible Edition clusters that run version 20.8 or later support connections using the MySQL protocol.
Notes
Connecting to an ApsaraDB for ClickHouse cluster using the MySQL protocol can result in performance loss and compatibility issues. Use this method with caution.
Prerequisites
The MySQL protocol is enabled. For more information, see Enable the MySQL protocol.
The IP address of the connection source is added to the whitelist of the ApsaraDB for ClickHouse cluster. For more information, see Configure a whitelist.
If the connection source and the ApsaraDB for ClickHouse cluster are in different VPCs, you must apply for a public endpoint for the ApsaraDB for ClickHouse cluster.
Procedure
Connect to the ApsaraDB for ClickHouse cluster using its public endpoint or VPC endpoint. The syntax is as follows.
mysql -h <endpoint> -P <mysql_port> -u <database_account> -p<password> --default-auth=mysql_native_passwordExample:
mysql -h cc-bp163l724nkf****.clickhouse.ads.aliyuncs.com -P 9004 -u test -p123456Aa --default-auth=mysql_native_passwordNoteThe MySQL port is 9004.
After you connect to the ApsaraDB for ClickHouse cluster, query the database. The query syntax is as follows.
show databases;The following result is returned.
+--------------------------------+ | name | +--------------------------------+ | _temporary_and_external_tables | | default | | system | +--------------------------------+