# MySQL / MariaDB

> Connect MySQL or MariaDB (including Amazon RDS, Aurora, Azure Database for MySQL and Cloud SQL) with a read-only user, pick tables, and load them in full or incrementally by an update column.

MySQL / MariaDB needs the Starter plan or above. DataxLand copies the tables you pick into the workspace's own warehouse through a
**read-only** session (`SET SESSION TRANSACTION READ ONLY`), streaming rows so large tables never fill memory; DataxLand never
writes to your database. It works with MySQL 5.7 and 8.x, MariaDB 10.x and 11.x, and compatible services (Amazon RDS, Aurora
MySQL, Azure Database for MySQL, Google Cloud SQL).

## 1. Prepare a user

Create a dedicated user for DataxLand that can only read the database you want to load:

```sql
CREATE USER 'dataxland'@'%' IDENTIFIED BY '<strong password>';
GRANT SELECT, SHOW VIEW ON your_database.* TO 'dataxland'@'%';
```

- `SELECT` is enough to read tables and list columns, primary keys and foreign keys; `SHOW VIEW` lets it read views.
- Don't grant `INSERT`, `UPDATE`, `DELETE`, `FILE`, `PROCESS` or `SUPER`: DataxLand doesn't need them.
- Replace `'%'` with DataxLand's server address to restrict where the user can sign in from (ask support for it), and open your
  firewall for that address.

## 2. Connect

1. **Data sources → Add source**, choose **MySQL / MariaDB**.
2. Fill in **Host**, **Port** (3306 by default), **Database name**, **User** and **Password**.
3. **SSL**:
   - **prefer** (default): encrypts if the server supports it.
   - **require**: encryption required, self-signed certificates accepted; if the server has no TLS, the connection fails and no
     data is sent.
   - **verify-full**: encryption required and the certificate must be issued by a public CA for the right host name (Azure and
     Cloud SQL use public certificates; Amazon RDS uses its own CA, so choose require).
   - **disable**: no encryption; only on a trusted network.
4. Click **Test connection**, pick tables (optionally **Filter by date (optional)**), then add the source.
   The password is encrypted at rest and never shown again.

## 3. Sync modes

MySQL / MariaDB supports **Full** and **Incremental**. Incremental needs a cursor column (DataxLand suggests columns such as
`updated_at` or `modified_at`) and a primary key to merge rows; each refresh reads rows whose cursor is newer than last time
(minus a 10-minute safety margin). The column should have `ON UPDATE CURRENT_TIMESTAMP` so every edit changes its value.
Incremental doesn't see deleted rows; binlog-based CDC is not supported for MySQL today. See
[Sync modes and refresh schedule](/en/docs/concepts/sync-modes).

## Data types

Data lands in the warehouse as is, as text; the data dictionary records each type so the standardisation step reads it correctly:

| MySQL type | In the dictionary | Notes |
| --- | --- | --- |
| `tinyint`, `smallint`, `int`, `bigint` (including `unsigned`), `year` | BIGINT | |
| `decimal`, `float`, `double` | DECIMAL | all decimal places kept |
| `bit(1)` | BOOLEAN | `true`/`false`; other `bit(n)` read as numbers |
| `date` | DATE | the date `0000-00-00` becomes empty |
| `datetime`, `timestamp` | DATETIME | `timestamp` is read in Vietnam time (UTC+7) |
| `time`, `char`, `varchar`, `text`, `enum`, `set`, `json` | VARCHAR | `time` as `HH:MM:SS` |
| `blob`, `binary` | (left empty) | binary data isn't used |

## Si investigates with SQL

As with PostgreSQL, Si may run read-only SQL on the source while investigating, within limits on the number of statements and
their cost (estimated with `EXPLAIN`); statements over the limit wait for a technical person to confirm them.

## Related

- [PostgreSQL](/en/docs/sources/postgres)
- [SQL Server / Azure SQL](/en/docs/sources/mssql)
- [Security and privacy](/en/docs/security-privacy)
