# START REPLICA

{% hint style="info" %}
The terms *master* and *slave* have historically been used in replication, and MariaDB has begun the process of adding *primary* and *replica* synonyms. The old terms will continue to be used to maintain backward compatibility - see [MDEV-18777](https://jira.mariadb.org/browse/MDEV-18777) to follow progress on this effort.
{% endhint %}

## Syntax

```sql
START { SLAVE | REPLICA } ["connection_name"] [thread_type [, thread_type] ... ]
START { SLAVE | REPLICA } ["connection_name"] [SQL_THREAD] UNTIL                
    MASTER_LOG_FILE = 'log_name', MASTER_LOG_POS = log_pos 
START { SLAVE | REPLICA } ["connection_name"] [SQL_THREAD] UNTIL
    RELAY_LOG_FILE = 'log_name', RELAY_LOG_POS = log_pos 
START { SLAVE | REPLICA } ["connection_name"] [SQL_THREAD] UNTIL
    MASTER_GTID_POS = <GTID position> 
START ALL { SLAVES | REPLICAS } [thread_type [, thread_type]] 

thread_type: IO_THREAD | SQL_THREAD
```

## Description

{% tabs %}
{% tab title="Current" %}
`START REPLICA` is a synonym for `START SLAVE`, which is considered deprecated.
{% endtab %}

{% tab title="< 10.5.1" %}
Only `START SLAVE` can be used.
{% endtab %}
{% endtabs %}

`START SLAVE` or `START REPLICA` with no thread\_type options starts both of the replica threads (see [replication](https://mariadb.com/docs/server/ha-and-performance/standard-replication)) needed to connect with a master setup with [CHANGE MASTER TO.](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/replication-statements/change-master-to) The I/O thread reads events from the primary server and stores them in the [relay log](https://mariadb.com/docs/server/server-management/server-monitoring-logs/binary-log/relay-log). The SQL thread reads events from the relay log and executes them.

{% tabs %}
{% tab title="Current" %}
`START REPLICA` requires the [REPLICATION SLAVE ADMIN](https://mariadb.com/docs/server/reference/account-management-sql-statements/grant#replication-slave-admin) privilege.
{% endtab %}

{% tab title="< 10.5.2" %}
`START REPLICA` requires the [SUPER](https://mariadb.com/docs/server/reference/account-management-sql-statements/grant#super) privilege.
{% endtab %}
{% endtabs %}

If `START REPLICA` succeeds in starting the replica threads, it returns without any error. However, even in that case, it might be that the replica threads start and then later stop (for example, because they do not manage to connect to the primary or read its [binary log](https://mariadb.com/docs/server/server-management/server-monitoring-logs/binary-log), or some other problem). `START REPLICA` does not warn you about this. You must check the replica's [error log](https://mariadb.com/docs/server/server-management/server-monitoring-logs/error-log) for error messages generated by the replica threads or check that they are running satisfactorily with [SHOW REPLICA STATUS](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-replica-status) ([SHOW REPLICA STATUS](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-replica-status)).

#### START REPLICA UNTIL

`START REPLICA UNTIL` refers to the `SQL_THREAD` replica position at which the `SQL_THREAD` replication will halt. If `SQL_THREAD` isn't specified, both threads are started.

`START REPLICA UNTIL master_gtid_pos=xxx` is also supported. See [Global Transaction ID/START REPLICA UNTIL master\_gtid\_pos=xxx](https://mariadb.com/docs/server/ha-and-performance/standard-replication/gtid) for more details.

**MariaDB starting with** [**11.3.0**](https://app.gitbook.com/s/aEnK0ZXmUbJzqQrTjFyb/community-server/old-releases/11.3/11.3.0)

{% tabs %}
{% tab title="Current" %}
**SQL\_BEFORE\_GTIDS|SQL\_AFTER\_GTIDS**

The `START REPLICA UNTIL` statement contains the options `SQL_BEFORE_GTIDS` and `SQL_AFTER_GTIDS` to allow control of whether the replica stops before or after a provided GTID state. Its syntax is:

```sql
START REPLICA UNTIL (SQL_BEFORE_GTIDS|SQL_AFTER_GTIDS)="<gtid_list>"
```

See [Global Transaction ID#SQL\_BEFORE\_GTIDS/SQL\_AFTER\_GTIDS](https://mariadb.com/docs/server/ha-and-performance/standard-replication/gtid#sql_before_gtidssql_after_gtids) for details.
{% endtab %}

{% tab title="< 11.3" %}
`SQL_BEFORE_GTIDS` and `SQL_AFTER_GTIDS` are not available.
{% endtab %}
{% endtabs %}

#### connection\_name

If there is only one nameless primary, or the default primary (as specified by the [default\_master\_connection](https://mariadb.com/docs/server/ha-and-performance/standard-replication/replication-and-binary-log-system-variables) system variable) is intended, `connection_name` can be omitted. If provided, the `START REPLICA` statement will apply to the specified primary. `connection_name` is case-insensitive.

{% tabs %}
{% tab title="Current" %}
The `FOR CHANNEL` keyword is available for MySQL compatibility. This is identical to using the channel\_name directly after `START REPLICA`.
{% endtab %}

{% tab title="< 10.7.0" %}
The `FOR CHANNEL` keyword is not available.
{% endtab %}
{% endtabs %}

#### START ALL REPLICAS

`START ALL REPLICAS` starts all configured replicas (replicas with master\_host not empty) that were not started before. It will give a `note` for all started connections. You can check the notes with [SHOW WARNINGS](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/show/show-warnings).

## See Also

* [Setting up replication](https://mariadb.com/docs/server/ha-and-performance/standard-replication/setting-up-replication).
* [CHANGE MASTER TO](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/replication-statements/change-master-to) is used to create and change connections.
* [STOP REPLICA](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/replication-statements/stop-replica) is used to stop a running connection.
* [RESET REPLICA](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/replication-statements/reset-replica) is used to reset parameters for a connection and also to permanently delete a primary connection.

<sub>*This page is licensed: GPLv2, originally from*</sub> [<sub>*fill\_help\_tables.sql*</sub>](https://github.com/MariaDB/server/blob/main/scripts/fill_help_tables.sql)

{% @marketo/form formId="4316" %}
