# Read-Only Replicas

A common [replication](/docs/server/ha-and-performance/standard-replication.md) setup is to have the replicas [read-only](/docs/server/server-management/variables-and-modes/server-system-variables.md#read_only) to ensure that no one\
accidentally updates them. If the replica has [binary logging enabled](/docs/server/ha-and-performance/standard-replication/setting-up-replication.md) and [gtid\_strict\_mode](/docs/server/ha-and-performance/standard-replication/gtid.md#gtid_strict_mode) is used, then any update that causes changes to the [binary log](/docs/server/server-management/server-monitoring-logs/binary-log.md) will stop replication.

When the variable `read_only` is set to 1, no updates are permitted except from users with the [SUPER](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#super) privilege (<= [MariaDB 10.5.1](/docs/release-notes/community-server/old-releases/10.5/10.5.1.md)) or [READ ONLY ADMIN](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#read_only-admin) privilege (>= [MariaDB 10.5.2](/docs/release-notes/community-server/old-releases/10.5/10.5.2.md)) or replica servers updating from a primary. Inserting rows to log tables, updates to temporary tables and [OPTIMIZE TABLE](/docs/server/ha-and-performance/optimization-and-tuning/optimizing-tables/optimize-table.md) or [ANALYZE TABLE](/docs/server/reference/sql-statements/table-statements/analyze-table.md) statements on temporary tables are excluded from this limitation.

If read\_only is set to 1, then the [SET PASSWORD](/docs/server/reference/sql-statements/account-management-sql-statements/set-password.md) statement is limited only to users with the [SUPER](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#super) privilege (<= [MariaDB 10.5.1](/docs/release-notes/community-server/old-releases/10.5/10.5.1.md)) or [READ ONLY ADMIN](/docs/server/reference/sql-statements/account-management-sql-statements/grant.md#read_only-admin) privilege (>= [MariaDB 10.5.2](/docs/release-notes/community-server/old-releases/10.5/10.5.2.md)).

Attempting to set the `read_only` variable to 1 will fail if the current session has table locks or transactions pending.

The statement will wait for other sessions that hold table locks. While the attempt to set read\_only is waiting, other requests for table locks or transactions will also wait until read\_only has been set.

### Older MariaDB Versions

If you are using an older MariaDB version with read-only replicas and binary logging enabled on the replica, and you need to do some changes but don't want to have them logged to the binary log, the easiest way to avoid the logging is to [disable binary logging](/docs/server/server-management/server-monitoring-logs/binary-log/activating-the-binary-log.md) while running as root during maintenance:

```sql
SET sql_log_bin=0;
ALTER TABLE test ENGINE=rocksdb;
```

The above changes the test table on the replica to rocksdb without registering\
the change in the binary log.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

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


---

# 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://mariadb.com/docs/server/ha-and-performance/standard-replication/read-only-replicas.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.
