# MySQL

### Manage access

* Create a dedicated user and give it the super user role as Synece requires a superuser to access binary logs for replication

### Enable bin log

You must enable binary logging for MySQL replication. The binary logs record transaction updates for replication tools to propagate changes.

1. Check whether the `log-bin` option is already on:

   `// for MySql 5.x` \
   `mysql> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::" FROM information_schema.global_variables WHERE variable_name='log_bin';`\
   \
   `// for MySql 8.x`\
   `mysql> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::" FROM performance_schema.global_variables WHERE variable_name='log_bin';`
2. If it is `OFF`, configure your MySQL server configuration file with the following properties, which are described in the table below:

   `server-id = 223344;`\
   `log_bin = mysql-bin`\
   `binlog_format = ROW`\
   `binlog_row_image = FULL`\
   `binlog_expire_logs_seconds = 864000`
3. Confirm your changes by checking the binlog status once more:

   `// for MySql 5.x`\
   `mysql> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::" FROM information_schema.global_variables WHERE variable_name='log_bin';`\
   \
   `// for MySql 8.x`\
   `mysql> SELECT variable_value as "BINARY LOGGING STATUS (log-bin) ::" FROM performance_schema.global_variables WHERE variable_name='log_bin';`
4. If you run MySQL on Amazon RDS, you must enable automated backups for your database instance for binary logging to occur. If the database instance is not configured to perform automated backups, the binlog is disabled, even if you apply the settings described in the previous steps.

### Enable GTIDs if you are using replica servers

Global transaction identifiers (GTIDs) uniquely identify transactions that occur on a server within a cluster. Though not required for a Debezium MySQL connector, using GTIDs simplifies replication and enables you to more easily confirm if primary and replica servers are consistent.

1. Enable `gtid_mode`:

   `mysql> gtid_mode=ON`
2. Enable `enforce_gtid_consistency`:

   `mysql> enforce_gtid_consistency=ON`
3. Confirm the changes:

   `mysql> show global variables like '%GTID%';`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.synece.com/supported-databases/mysql.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
