cloud sql mysql database instance binlog is keep increasing

CloudSQL for MySQL should automatically purge binary logs after 7 days by default. However, there are a few reasons why this might not be happening:

  1. Custom Configuration: If the binlog_expire_logs_seconds flag has been set to a value greater than 604800 (7 days in seconds), then binary logs will be kept for longer than 7 days. Check your Cloud SQL instance’s flags to see if this is the case.

  2. Active Connections: If there are active connections that are still reading from a binary log file, that file cannot be purged. This is often the case with replication, where a replica might be lagging behind and still reading from an old binary log file. In this case, you would need to ensure that all replicas have read the binary log file before it can be purged.