|
| 1 | +--- |
| 2 | +sidebar_label: 'Generic MySQL' |
| 3 | +description: 'Set up any MySQL instance as a source for ClickPipes' |
| 4 | +slug: /integrations/clickpipes/mysql/source/generic |
| 5 | +title: 'Generic MySQL source setup guide' |
| 6 | +--- |
| 7 | + |
| 8 | +# Generic MySQL source setup guide |
| 9 | + |
| 10 | +:::info |
| 11 | + |
| 12 | +If you use one of the supported providers (in the sidebar), please refer to the specific guide for that provider. |
| 13 | + |
| 14 | +::: |
| 15 | + |
| 16 | +## Enable binary log retention {#enable-binlog-retention} |
| 17 | + |
| 18 | +Binary logs contain information about data modifications made to a MySQL server instance and are required for replication. |
| 19 | + |
| 20 | +### MySQL 8.x and newer {#binlog-v8-x} |
| 21 | + |
| 22 | +To enable binary logging on your MySQL instance, ensure that the following settings are configured: |
| 23 | + |
| 24 | +```sql |
| 25 | +log_bin = ON -- default value |
| 26 | +binlog_format = ROW -- default value |
| 27 | +binlog_row_image = FULL -- default value |
| 28 | +binlog_row_metadata = FULL |
| 29 | +binlog_expire_logs_seconds = 86400 -- 1 day or higher; default is 30 days |
| 30 | +``` |
| 31 | + |
| 32 | +To check these settings, run the following SQL commands: |
| 33 | +```sql |
| 34 | +SHOW VARIABLES LIKE 'log_bin'; |
| 35 | +SHOW VARIABLES LIKE 'binlog_format'; |
| 36 | +SHOW VARIABLES LIKE 'binlog_row_image'; |
| 37 | +SHOW VARIABLES LIKE 'binlog_row_metadata'; |
| 38 | +SHOW VARIABLES LIKE 'binlog_expire_logs_seconds'; |
| 39 | +``` |
| 40 | + |
| 41 | +If the values don't match, you can run the following SQL commands to set them: |
| 42 | +```sql |
| 43 | +SET PERSIST log_bin = ON; |
| 44 | +SET PERSIST binlog_format = ROW; |
| 45 | +SET PERSIST binlog_row_image = FULL; |
| 46 | +SET PERSIST binlog_row_metadata = FULL; |
| 47 | +SET PERSIST binlog_expire_logs_seconds = 86400; |
| 48 | +``` |
| 49 | + |
| 50 | +If you have changed the `log_bin` setting, you NEED to RESTART the MySQL instance for the changes to take effect. |
| 51 | + |
| 52 | +After changing the settings, continue on with [configuring a database user](#configure-database-user). |
| 53 | + |
| 54 | +### MySQL 5.7 {#binlog-v5-x} |
| 55 | + |
| 56 | +To enable binary logging on your MySQL 5.7 instance, ensure that the following settings are configured: |
| 57 | + |
| 58 | +```sql |
| 59 | +server_id = 1 -- or greater; anything but 0 |
| 60 | +log_bin = ON |
| 61 | +binlog_format = ROW -- default value |
| 62 | +binlog_row_image = FULL -- default value |
| 63 | +expire_logs_days = 1 -- or higher; 0 would mean logs are preserved forever |
| 64 | +``` |
| 65 | + |
| 66 | +To check these settings, run the following SQL commands: |
| 67 | +```sql |
| 68 | +SHOW VARIABLES LIKE 'server_id'; |
| 69 | +SHOW VARIABLES LIKE 'log_bin'; |
| 70 | +SHOW VARIABLES LIKE 'binlog_format'; |
| 71 | +SHOW VARIABLES LIKE 'binlog_row_image'; |
| 72 | +SHOW VARIABLES LIKE 'expire_logs_days'; |
| 73 | +``` |
| 74 | + |
| 75 | +If the values don't match, you can set them in the config file (typically at `/etc/my.cnf` or `/etc/mysql/my.cnf`): |
| 76 | +```ini |
| 77 | +[mysqld] |
| 78 | +server_id = 1 |
| 79 | +log_bin = ON |
| 80 | +binlog_format = ROW |
| 81 | +binlog_row_image = FULL |
| 82 | +expire_logs_days = 1 |
| 83 | +``` |
| 84 | + |
| 85 | +You NEED to RESTART the MySQL instance for the changes to take effect. |
| 86 | + |
| 87 | +:::note |
| 88 | + |
| 89 | +Column exclusion is not supported for MySQL 5.7 because the `binlog_row_metadata` setting wasn't yet introduced. |
| 90 | + |
| 91 | +::: |
| 92 | + |
| 93 | +## Configure a database user {#configure-database-user} |
| 94 | + |
| 95 | +Connect to your MySQL instance as the root user and execute the following commands: |
| 96 | + |
| 97 | +1. Create a dedicated user for ClickPipes: |
| 98 | + |
| 99 | + ```sql |
| 100 | + CREATE USER 'clickpipes_user'@'%' IDENTIFIED BY 'some_secure_password'; |
| 101 | + ``` |
| 102 | + |
| 103 | +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: |
| 104 | + |
| 105 | + ```sql |
| 106 | + GRANT SELECT ON `clickpipes`.* TO 'clickpipes_user'@'%'; |
| 107 | + ``` |
| 108 | + |
| 109 | +3. Grant replication permissions to the user: |
| 110 | + |
| 111 | + ```sql |
| 112 | + GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%'; |
| 113 | + GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%'; |
| 114 | + ``` |
| 115 | + |
| 116 | +:::note |
| 117 | + |
| 118 | +Make sure to replace `clickpipes_user` and `some_secure_password` with your desired username and password. |
| 119 | + |
| 120 | +::: |
| 121 | + |
| 122 | +## SSL/TLS configuration (recommended) {#ssl-tls-configuration} |
| 123 | + |
| 124 | +SSL certificates ensure secure connections to your MySQL database. Configuration depends on your certificate type: |
| 125 | + |
| 126 | +**Trusted Certificate Authority (DigiCert, Let's Encrypt, etc.)** - no additional configuration needed. |
| 127 | +
|
| 128 | +**Internal Certificate Authority** - Obtain the root CA certificate file from your IT team. In the ClickPipes UI, upload it when creating a new MySQL ClickPipe. |
| 129 | +
|
| 130 | +**Self-hosted MySQL** - Copy the CA certificate from your MySQL server (typically at `/var/lib/mysql/ca.pem`) and upload it in the UI when creating a new MySQL ClickPipe. Use the IP address of the server as the host. |
| 131 | +
|
| 132 | +**Self-hosted MySQL without server access** - Contact your IT team for the certificate. As a last resort, use the "Skip Certificate Verification" toggle in ClickPipes UI (not recommended for security reasons). |
| 133 | +
|
| 134 | +For more information on SSL/TLS options, check out our [FAQ](https://clickhouse.com/docs/integrations/clickpipes/mysql/faq#tls-certificate-validation-error). |
| 135 | +
|
| 136 | +## What's next? {#whats-next} |
| 137 | + |
| 138 | +You can now [create your ClickPipe](../index.md) and start ingesting data from your MySQL instance into ClickHouse Cloud. |
| 139 | +Make sure to note down the connection details you used while setting up your MySQL instance as you will need them during the ClickPipe creation process. |
0 commit comments