> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-home-button.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Step-by-step guide on how to set up Amazon RDS MySQL as a source for ClickPipes

# RDS MySQL source setup guide

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

This step-by-step guide shows you how to configure Amazon RDS MySQL to replicate data into ClickHouse Cloud using the [MySQL ClickPipe](/integrations/clickpipes/mysql). For common questions around MySQL CDC, see the [MySQL FAQs page](/integrations/clickpipes/mysql/faq).

<h2 id="enable-binlog-retention-rds">
  Enable binary log retention
</h2>

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. To configure binary log retention in RDS MySQL, you must [enable binary logging](#enable-binlog-logging) and [increase the binlog retention interval](#binlog-retention-interval).

<h3 id="enable-binlog-logging">
  1. Enable binary logging via automated backup
</h3>

The automated backups feature determines whether binary logging is turned on or off for MySQL. Automated backups can be configured for your instance in the RDS Console by navigating to **Modify** > **Additional configuration** > **Backup** and selecting the **Enable automated backups** checkbox (if not selected already).

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=1cc80fa60e4de4d69123cecd0b47c6ff" alt="Enabling automated backups in RDS" size="lg" border width="3230" height="530" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.png" />

We recommend setting the **Backup retention period** to a reasonably long value, depending on the replication use case.

<h3 id="binlog-retention-interval">
  2. Increase the binlog retention interval
</h3>

<Warning>
  If ClickPipes tries to resume replication and the required binlog files have been purged due to the configured binlog retention value, the ClickPipe will enter an errored state and a resync is required.
</Warning>

By default, Amazon RDS purges the binary log as soon as possible (i.e., *lazy purging*). We recommend increasing the binlog retention interval to at least **72 hours** to ensure availability of binary log files for replication under failure scenarios. To set an interval for binary log retention ([`binlog retention hours`](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration-usage-notes.binlog-retention-hours)), use the [`mysql.rds_set_configuration`](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration) procedure:

[//]: # "NOTE Most CDC providers recommend the maximum retention period for RDS (7 days/168 hours). Since this has an impact on disk usage, we conservatively recommend a minimum of 3 days/72 hours."

```text theme={null}
mysql=> call mysql.rds_set_configuration('binlog retention hours', 72);
```

If this configuration isn't set or is set to a low interval, it can lead to gaps in the binary logs, compromising ClickPipes' ability to resume replication.

<h2 id="binlog-settings">
  Configure binlog settings
</h2>

The parameter group can be found when you click on your MySQL instance in the RDS Console, and then navigate to the **Configuration** tab.

<Tip>
  If you have a MySQL cluster, the parameters below can be found in the [DB cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) parameter group instead of the DB instance group.
</Tip>

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/rds_config.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=2780db2d96968014f5b490080d691681" alt="Where to find parameter group in RDS" size="lg" border width="708" height="853" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/rds_config.png" />

<br />

Click the parameter group link, which will take you to its dedicated page. You should see an **Edit** button in the top right.

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/edit_button.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=6eb9c5e2a02036e3d94d5164cd5e56d9" alt="Edit parameter group" size="lg" border width="1662" height="292" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/edit_button.png" />

The following parameters need to be set as follows:

1. `binlog_format` to `ROW`.

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=3aba0ff1f1b5f89b511ef4acc0382292" alt="Binlog format to ROW" size="lg" border width="960" height="232" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.png" />

2. `binlog_row_metadata` to `FULL`

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_metadata.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=3dd4a01b558beb8742b45a15fe62c798" alt="Binlog row metadata to FULL" size="lg" border width="934" height="234" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_metadata.png" />

3. `binlog_row_image` to `FULL`

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=55683f9e11951f1a281c3d6a73e974b7" alt="Binlog row image to FULL" size="lg" border width="934" height="234" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.png" />

<br />

Then, click on **Save Changes** in the top right corner. You may need to reboot your instance for the changes to take effect — a way of knowing this is if you see `Pending reboot` next to the parameter group link in the **Configuration** tab of the RDS instance.

<h2 id="gtid-mode">
  Enable GTID Mode
</h2>

<Tip>
  The MySQL ClickPipe also supports replication without GTID mode. However, enabling GTID mode is recommended for better performance and easier troubleshooting.
</Tip>

[Global Transaction Identifiers (GTIDs)](https://dev.mysql.com/doc/refman/8.0/en/replication-gtids.html) are unique IDs assigned to each committed transaction in MySQL. They simplify binlog replication and make troubleshooting more straightforward. We **recommend** enabling GTID mode, so that the MySQL ClickPipe can use GTID-based replication.

GTID-based replication is supported for Amazon RDS for MySQL versions 5.7, 8.0 and 8.4. To enable GTID mode for your Aurora MySQL instance, follow these steps:

1. In the RDS Console, click on your MySQL instance.
2. Click on the **Configuration** tab.
3. Click on the parameter group link.
4. Click on the **Edit** button in the top right corner.
5. Set `enforce_gtid_consistency` to `ON`.
6. Set `gtid-mode` to `ON`.
7. Click on **Save Changes** in the top right corner.
8. Reboot your instance for the changes to take effect.

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/enable_gtid.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=9855026f494dae81fec53b43fe098a87" alt="GTID enabled" size="lg" border width="1650" height="469" data-path="images/integrations/data-ingestion/clickpipes/mysql/enable_gtid.png" />

<br />

<Tip>
  The MySQL ClickPipe also supports replication without GTID mode. However, enabling GTID mode is recommended for better performance and easier troubleshooting.
</Tip>

<h2 id="configure-database-user">
  Configure a database user
</h2>

Connect to your RDS MySQL instance as an admin user and execute the following commands:

1. Create a dedicated user for ClickPipes:

   ```sql theme={null}
   CREATE USER 'clickpipes_user'@'host' IDENTIFIED BY 'some-password';
   ```

2. Grant schema permissions. The following example shows permissions for the `mysql` database. Repeat these commands for each database and host you want to replicate:

   ```sql theme={null}
   GRANT SELECT ON `mysql`.* TO 'clickpipes_user'@'host';
   ```

3. Grant replication permissions to the user:

   ```sql theme={null}
   GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%';
   GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%';
   ```

<h2 id="configure-network-access">
  Configure network access
</h2>

<h3 id="ip-based-access-control">
  IP-based access control
</h3>

To restrict traffic to your Aurora MySQL instance, add the [documented static NAT IPs](/integrations/clickpipes/home#list-of-static-ips) to the **Inbound rules** of your RDS security group.

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/St1M90JquFFJKAOf/images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.png?fit=max&auto=format&n=St1M90JquFFJKAOf&q=85&s=2b5e0ec24f84a8c9d75c9617605c2b77" alt="Where to find security group in RDS MySQL?" size="lg" border width="2850" height="994" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.png" />

<Image img="https://mintcdn.com/private-7c7dfe99-home-button/u7z0gNe6GWCJXTn9/images/integrations/data-ingestion/clickpipes/postgres/source/rds/edit_inbound_rules.png?fit=max&auto=format&n=u7z0gNe6GWCJXTn9&q=85&s=9e6f4ef77eea185feb54ae7728ac5c3f" alt="Edit inbound rules for the above security group" size="lg" border width="1800" height="935" data-path="images/integrations/data-ingestion/clickpipes/postgres/source/rds/edit_inbound_rules.png" />

<h3 id="private-access-via-aws-privatelink">
  Private access via AWS PrivateLink
</h3>

To connect to your RDS instance through a private network, you can use AWS PrivateLink. Follow the [AWS PrivateLink setup guide for ClickPipes](/resources/support-center/knowledge-base/cloud-services/aws-privatelink-setup-for-clickpipes) to set up the connection.

<h2 id="next-steps">
  Next steps
</h2>

Now that your Amazon RDS MySQL instance is configured for binlog replication and securely connecting to ClickHouse Cloud, you can [create your first MySQL ClickPipe](/integrations/clickpipes/mysql#create-your-clickpipe). For common questions around MySQL CDC, see the [MySQL FAQs page](/integrations/clickpipes/mysql/faq).
