---
title: "Integrating ClickHouse with MySQL"
description: "Perfom SELECT and INSERT operations on data stored on a remote MySQL server directly from ClickHouse"
category: "DATA_INGESTION"
support: "CORE"
docs: "https://clickhouse.com/docs/integrations/connectors/data-sources/mysql"
---

# MySQL

> **Note:** It's possible that you need to authorize ClickHouse Cloud to access to your MySQL instance. The full list of ClickHouse Cloud egress IP addresses is available <a href="https://clickhouse.com/docs/en/manage/security/ip-egress-traffic-list" target="_blank">here</a>.

### Use the the MySQL table function
You can use the MySQL table function to query remote MySQL tables.

```sql
SELECT * FROM mysql('<mysql_host>:<port>', '<database>', '<table>', '<user>', '<password>');
```

### Create a MySQL table without providing a schema

You can also create a table using PostgreSQL table engine in your ClickHouse Cloud service without specifying a schema using the `CREATE TABLE AS` syntax. When ClickHouse creates the table locally, types in MySQL will be mapped to equivalent ClickHouse types.

``` sql
CREATE TABLE mycountries AS mysql('<mysql_host>:<port>', '<database>', '<table>', '<user>', '<password>');
``` 

> **Note:** You can use the setting `external_table_functions_use_nulls = 0` to ensure Null values are represented as their default values (instead of Null). If set to 1 (the default), ClickHouse will create Nullable variants of each column.


### Create a MySQL table with a custom schema

You can also decide to create a table with the MySQL table engine in your ClickHouse service by specifying a custom schema. 

``` sql
CREATE TABLE default.mysql_table
(
    `float_nullable` Nullable(Float32),
    `str` String,
    `int_id` Int32
)
ENGINE = mysql('<mysql_host>:<port>', '<database>', '<table>', '<user>', '<password>')
```
