title_wip

[Edit this page](https://github.com/ClickHouse/clickhouse-docs/blob/main/docs/integrations/data-ingestion/clickpipes/mysql/source/gcp.md)

This is a step-by-step guide on how to configure your Cloud SQL for MySQL instance for replicating its data via the MySQL ClickPipe.

## Enable binary log retention[​](#enable-binlog-retention-gcp "Direct link to Enable binary log retention")

The binary log is a set of log files that contain information about data modifications made to an MySQL server instance, and binary log files are required for replication.

### Enable binary logging via PITR[​](#enable-binlog-logging-gcp "Direct link to Enable binary logging via PITR")

The PITR feature determines whether binary logging is turned on or off for MySQL in Google Cloud. It can be set in the Cloud console, by editing your Cloud SQL instance and scrolling down to the below section.

Setting the value to a reasonably long value depending on the replication use-case is advisable.

If not already configured, make sure to set these in the database flags section by editing the Cloud SQL:

1. `binlog_expire_logs_seconds` to a value >= `86400` (1 day).
2. `binlog_row_metadata` to `FULL`
3. `binlog_row_image` to `FULL`

To do this, click on the `Edit` button in the top right corner of the instance overview page.

Then scroll down to the `Flags` section and add the above flags.

## Configure a database user[​](#configure-database-user-gcp "Direct link to Configure a database user")

Connect to your Cloud SQL MySQL instance as the root user and execute the following commands:

1. Create a dedicated user for ClickPipes:

   ```
   CREATE USER 'clickpipes_user'@'host' IDENTIFIED BY 'some-password';
   ```
2. Grant schema permissions. The following example shows permissions for the `clickpipes` database. Repeat these commands for each database and host you want to replicate:

   ```
   GRANT SELECT ON `clickpipes`.* TO 'clickpipes_user'@'host';
   ```
3. Grant replication permissions to the user:

   ```
   GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%';
   GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%';
   ```

## Configure network access[​](#configure-network-access-gcp-mysql "Direct link to Configure network access")

If you want to restrict traffic to your Cloud SQL instance, please add the [documented static NAT IPs](/docs/integrations/clickpipes#list-of-static-ips) to the allowlisted IPs of your Cloud SQL MySQL instance.
This can be done either by editing the instance or by heading over to the `Connections` tab in the sidebar in Cloud console.

## Download and use root CA certificate[​](#download-root-ca-certificate-gcp-mysql "Direct link to Download and use root CA certificate")

To connect to your Cloud SQL instance, you need to download the root CA certificate.

1. Go to your Cloud SQL instance in the Cloud console.
2. Click on `Connections` in the sidebar.
3. Click on the `Security` tab.
4. In the `Manage server CA certificates` section, click on the `DOWNLOAD CERTIFICATES` button at the bottom.

5. In the ClickPipes UI, upload the downloaded certificate when creating a new MySQL ClickPipe.

- [Enable binary log retention](#enable-binlog-retention-gcp)
  - [Enable binary logging via PITR](#enable-binlog-logging-gcp)- [Configure a database user](#configure-database-user-gcp)- [Configure network access](#configure-network-access-gcp-mysql)- [Download and use root CA certificate](#download-root-ca-certificate-gcp-mysql)

Was this page helpful?