Error
Error Code: 1836

MySQL Error 1836: Server in Read-Only Mode

📦 MySQL
📋

Description

This error indicates that the MySQL server or your current session is configured to disallow write operations such as INSERT, UPDATE, DELETE, or DDL statements. It typically occurs when you attempt to modify data or schema on a server that is intentionally set to a read-only state.
💬

Error Message

Running in read-only mode
🔍

Known Causes

3 known causes
⚠️
Replication Slave Server
The server is acting as a replication slave, which is often configured as read-only to ensure data consistency with the master and handle read queries.
⚠️
Administrator-Set Read-Only State
An administrator has intentionally enabled read-only mode for maintenance, backup operations, or as part of a disaster recovery strategy to prevent data changes.
⚠️
Global `read_only` Variable Enabled
The `read_only` system variable has been explicitly set to `ON` globally or for your session, preventing all write operations.
🛠️

Solutions

3 solutions available

1. Temporarily Disable Read-Only Mode easy

Quickly enable write operations by setting the read_only variable.

1
Connect to your MySQL server as a user with sufficient privileges (e.g., root).
2
Execute the following SQL command to disable read-only mode for the current session. This is a temporary fix and will revert upon server restart.
SET GLOBAL read_only = OFF;
3
Alternatively, if you only want to disable it for your current connection:
SET SESSION read_only = OFF;

2. Permanently Disable Read-Only Mode (Configuration File) medium

Modify the MySQL configuration file to disable read-only mode permanently.

1
Locate your MySQL configuration file. Common locations include `/etc/my.cnf`, `/etc/mysql/my.cnf`, or `/etc/mysql/mysql.conf.d/mysqld.cnf`.
2
Open the configuration file with a text editor (e.g., `nano`, `vim`) with root privileges.
sudo nano /etc/mysql/my.cnf
3
Find the `[mysqld]` section and look for a line that sets `read_only` or `super_read_only`. If it's set to `1`, change it to `0` or comment out the line entirely.
[mysqld]
# read_only = 1
4
Save the changes to the configuration file.
5
Restart the MySQL service for the changes to take effect.
sudo systemctl restart mysql

3. Check Replication Status for Read-Only Trigger medium

Determine if read-only mode is enabled due to replication slave status.

1
Connect to your MySQL server with administrative privileges.
2
Check the current value of `read_only` and `super_read_only` variables.
SHOW GLOBAL VARIABLES LIKE 'read_only';
3
If `read_only` is `ON` (1) and you are using replication, this is likely the cause. If you need to write to this server, you might need to stop replication or promote it to a master.
SHOW GLOBAL VARIABLES LIKE 'super_read_only';
4
If `super_read_only` is `ON` (1), it's often set by replication slave configurations. To disable it (if appropriate for your setup), you can use the same method as the permanent configuration file change, targeting `super_read_only` instead of `read_only`.
[mysqld]
# super_read_only = 1
5
If you intend for this to be a writable master, ensure `read_only` and `super_read_only` are set to `OFF` (0) in your `my.cnf` file and restart the MySQL service.
🔗

Related Errors

5 related errors