Open-Source Wikis

/

ClickHouse

/

API

/

MySQL wire

clickhouse/clickhouse

MySQL wire

ClickHouse implements the MySQL wire protocol so existing MySQL tooling can connect without changes. Default port: 9004. Implementation: src/Server/MySQLHandler.cpp and src/Server/MySQLHandlerFactory.cpp, with parser/types support under src/Core/MySQL/ and src/Parsers/MySQL/.

mysql -h localhost -P 9004 -u user -p

What works

  • SELECT, INSERT, CREATE TABLE, ALTER, DROP.
  • ClickHouse-flavoured SQL (the dialect is ClickHouse, not MySQL — but most MySQL queries that don't use server-side functions land fine).
  • Parameterised statements (prepared statements).
  • Authentication: mysql_native_password, caching_sha2_password (default in MySQL 8+).
  • TLS via the configured server certificate.
  • Streaming result sets.

What doesn't

  • MySQL-specific server functions (@@version, INFORMATION_SCHEMA flavour quirks) are mapped where reasonable but not exhaustively.
  • Stored procedures, triggers, MySQL replication.
  • Some MySQL-only built-in functions.

The handler intentionally errs on the side of compatibility. When in doubt about a feature, it returns a clear error rather than silently misbehaving.

Mapping

src/Core/MySQL/MySQLReplication.cpp, MySQLPackets.cpp, MySQLClient.cpp, and the data-type mapping under src/DataTypes/DataTypeNumberBase.cpp translate ClickHouse types to MySQL column types:

  • Int* / UInt* → MySQL int types of matching width.
  • Float32 / Float64FLOAT / DOUBLE.
  • StringVARCHAR / TEXT.
  • Date, DateTime → MySQL DATE, DATETIME.
  • DecimalDECIMAL.
  • UUID, IPv4, IPv6, Enum* → string-ified.

Use cases

  • BI tools that speak MySQL (Tableau, Looker, Metabase) can query ClickHouse via JDBC's MySQL driver.
  • One-off mysql shell access.
  • Migration windows where you need to expose ClickHouse to MySQL-only consumers.

For new clients you control, prefer the native TCP or HTTP interface — they have less impedance mismatch.

MySQL-as-a-source

The reverse direction is also supported: MySQL table engine and mysql(...) table function let ClickHouse pull from a MySQL server. The replication-replica path uses src/Databases/MySQL/ and MaterializedMySQL engine to mirror an upstream MySQL database. See Other engines.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

MySQL wire – ClickHouse wiki | Factory