Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Integrating MySQL with ClickHouse
This page covers using theMySQL table engine, for reading from a MySQL table.
For ClickHouse Cloud, you can also use the MySQL ClickPipe (currently in public beta) to easily move data from your MySQL tables to ClickHouse.
Connecting ClickHouse to MySQL using the MySQL Table Engine
TheMySQL table engine allows you to connect ClickHouse to MySQL. SELECT and INSERT statements can be made in either ClickHouse or in the MySQL table. This article illustrates the basic methods of how to use the MySQL table engine.
- Configure MySQL
- Create a database in MySQL:
- Create a table:
- Insert sample rows:
- Create a user to connect from ClickHouse:
- Grant privileges as needed. (For demonstration purposes, the
mysql_clickhouseuser is granted admin privileges.)
If you’re using this feature in ClickHouse Cloud, you may need the to allow the ClickHouse Cloud IP addresses to access your MySQL instance.
Check the ClickHouse Cloud Endpoints API for egress traffic details.
- Define a Table in ClickHouse
- Now let’s create a ClickHouse table that uses the
MySQLtable engine:
| parameter | Description | example |
|---|---|---|
| host | hostname or IP | mysql-host.domain.com |
| database | mysql database name | db1 |
| table | mysql table name | table1 |
| user | username to connect to mysql | mysql_clickhouse |
| password | password to connect to mysql | Password123! |
View the MySQL table engine doc page for a complete list of parameters.
- Test the Integration
- In MySQL, insert a sample row:
- Notice the existing rows from the MySQL table are in the ClickHouse table, along with the new row you just added:
- Let’s add a row to the ClickHouse table:
- Notice the new row appears in MySQL:
Summary
TheMySQL table engine allows you to connect ClickHouse to MySQL to exchange data back and forth. For more details, be sure to check out the documentation page for the MySQL table engine.