# MySQL

## Introduction

MySQL is a widely-used, open-source relational database management system that uses SQL (Structured Query Language) for data manipulation. Known for its speed, reliability, and ease of use, MySQL is the foundation for many popular applications and websites. It powers critical backend systems and supports large-scale enterprise solutions.

Now you can seamlessly synchronize data across all your CRM and database systems using Stacksync!

## Things to keep in mind

### During setup

* [x] **All MySQL tables must have a (single) primary key**\
  We use the primary key to keep your data in sync.\
  The primary key must be a single column; composite primary keys are not supported.
* [x] **Primary keys must be auto-generated**\
  Ensure your primary keys are auto-generated by your database (e.g. use `AUTO_INCREMENT` for primary keys).
* [x] **Check user permissions**\
  Verify that the MySQL user used by Stacksync to connect to your database has sufficient privileges (e.g., `SELECT`, `INSERT`, `UPDATE`, and `DELETE`) on the tables you want to map.
* [x] **Run this query to check if Stacksync can create triggers:**

  ```sql
  SELECT
    CASE
      WHEN @@log_bin = 0 THEN '✅ Binary logging is OFF — No issues.'
      WHEN @@log_bin = 1 AND @@log_bin_trust_function_creators = 1 THEN '✅ Binary logging is ON — Trust is enabled — All good.'
      ELSE '⚠️  Binary logging is ON but trust_function_creators is OFF — Please fix to allow trigger creation.'
    END AS status;
  ```

  If you see ⚠️, it means you need to update the server settings (requires admin access).

  ```sql
  SET GLOBAL log_bin_trust_function_creators = 1;
  ```

  **Reason:**\
  Stackync creates deterministic triggers for internal logging and syncing.\
  By default, MySQL restricts non-super users from creating triggers when binary logging is enabled — unless `log_bin_trust_function_creators` is set to `ON`.

  Feel free to reach out to us at <hello@stacksync.com>

If a table in your database does not appear in Stacksync, one of the above conditions is likely not met. Check our MySQL snippets collection for troubleshooting tips.

### After setup

Renaming schemas, tables, or columns will break Stacksync configuration. But don't worry, we've got you covered! Refer to our [Update Sync Configuration](/two-way-sync/features/update-sync-configuration.md) guide for detailed steps to address this.


---

# 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.stacksync.com/two-way-sync/connectors/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.
