> ## Documentation Index
> Fetch the complete documentation index at: https://www.artie.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MariaDB source setup

> Configure MariaDB as a source in Artie with binlog replication, service account setup, and GTID support through Artie's MySQL connector.

Artie connects to MariaDB with its MySQL connector. It detects MariaDB from the server version and switches to MariaDB's binlog and GTID handling automatically, so there is nothing MariaDB-specific to configure in the Artie dashboard.

## What you'll need

* Database connection details
* A service account
* `binlog_format` set to `ROW`
* At least 24 hours of binlog retention

## Setup

**Step 1: Create a service account**

Run the following SQL to create a dedicated user for Artie:

```sql setup.sql
CREATE USER 'artie' IDENTIFIED BY 'password';
-- SELECT is required for backfills.
-- REPLICATION CLIENT and REPLICATION SLAVE are required for Artie to read the binary log.
GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'artie';
```

> **Note:**
>
> On MariaDB 10.5.2 and later, `REPLICATION CLIENT` is an alias for `BINLOG MONITOR`, so the same statement works on every version.

**Step 2: Enable binlog (ROW format)**

Binary logging must be enabled with `binlog_format` set to `ROW`.

**Amazon RDS for MariaDB**

**Step 1: Create a parameter group**

Navigate to **RDS** > **Parameter groups** > **Create parameter group**. Select the MariaDB family that matches your version.

**Step 2: Set binlog\_format to ROW**

Open the new parameter group, search for `binlog_format`, and set it to `ROW`.

**Step 3: Apply the parameter group**

Associate the parameter group with your RDS instance, then reboot the database for the change to take effect.

> **Note:**
>
> RDS only writes binary logs when automated backups are enabled. Make sure the backup retention period is greater than 0.

**Self-hosted MariaDB**

Add the following to your MariaDB configuration file (`my.cnf`, or a file under `/etc/mysql/mariadb.conf.d/`):

```ini
[mysqld]
log_bin = mariadb-bin
binlog_format = ROW
```

Then restart the MariaDB server.

**Step 3: Set binlog retention period**

Artie requires at least 24 hours of binlog retention.

**Amazon RDS for MariaDB**

```sql
CALL mysql.rds_set_configuration('binlog retention hours', 24);
```

**Self-hosted MariaDB**

MariaDB keeps binary logs until they are purged, which is the default. If you have set an expiry, make sure it is at least 24 hours:

```sql
-- MariaDB 10.6.1 and later
SET GLOBAL binlog_expire_logs_seconds = 86400;
-- Earlier versions
SET GLOBAL expire_logs_days = 1;
```

Add the same setting to your configuration file so it survives a restart.

**Step 4: Create the source in Artie**

When you create a pipeline, choose **MariaDB** as the source and enter your connection details. Artie creates a MySQL connector for it, so the source is listed as MySQL afterwards.

## Additional features

* **GTID support**: with `gtid_strict_mode` enabled, Artie resumes replication from GTIDs instead of binlog file positions.

**Enabling GTID**

MariaDB writes GTIDs to the binary log by default. Artie uses them once `gtid_strict_mode` is on, because strict mode guarantees that sequence numbers only increase within each replication domain.

```sql
SET GLOBAL gtid_strict_mode = ON;
```

Add `gtid_strict_mode = ON` to your configuration file as well (on RDS, set it in the parameter group). You can verify the settings with:

```sql
SHOW VARIABLES LIKE 'gtid_strict_mode';
SELECT @@gtid_binlog_pos;
```

`gtid_strict_mode` should be `ON` and `gtid_binlog_pos` should not be empty.

> **Info:**
>
> Without strict mode, Artie still replicates MariaDB by binlog file and position. Once strict mode is on, Artie detects it on the next restart and switches to GTID-based replication. No configuration is needed in the Artie dashboard.

## Frequently asked questions

### Which MariaDB versions are supported?

Artie supports MariaDB 10.6, 10.11, and 11 or higher. Amazon RDS for MariaDB uses the same setup, with the parameter group and retention steps shown above.

### Can I replicate from a read replica?

Yes, if the replica writes replicated changes to its own binary log. Artie reads the replica's local binary log, not its relay log.

Configure the replica with:

* `log_bin` enabled
* `binlog_format = ROW`
* `log_slave_updates = ON`
* A healthy replication connection
* At least 24 hours of local binlog retention

Use these queries on the replica to verify its configuration:

```sql
SHOW VARIABLES WHERE variable_name IN ('log_bin', 'binlog_format', 'log_slave_updates');
SHOW SLAVE STATUS;
SHOW BINARY LOGS;
```

### How do I verify that binlog is enabled?

Run the following queries on your MariaDB server:

```sql
SHOW VARIABLES LIKE 'log_bin';
SHOW VARIABLES LIKE 'binlog_format';
SHOW MASTER STATUS;
```

`log_bin` should be `ON`, `binlog_format` should be `ROW`, and `SHOW MASTER STATUS` should return the current binlog file and position.

### What happens if binlog retention is too short?

If binlog files are purged before Artie can read them, the pipeline will need to re-snapshot the affected tables. We recommend at least 24 hours of retention to provide a comfortable buffer.