Error
Error Code:
1621
MariaDB Error 1621: Modifying Read-Only Variable
Description
Error 1621 indicates an attempt to modify a MariaDB system variable that is marked as read-only. These variables are often crucial for the server's stability or security and cannot be changed dynamically using `SET` statements. This error typically occurs when a user tries to alter a variable that MariaDB explicitly prevents from being modified at runtime.
Error Message
%s variable '%s' is read-only. Use SET %s to assign the value
Known Causes
3 known causesImmutable System Variable
The variable you attempted to change is fundamentally read-only by design within MariaDB and cannot be altered after server startup or at all.
Configuration Restricted
The system variable has been explicitly set to a read-only state in the MariaDB server's configuration file (e.g., `my.cnf`) or via startup parameters.
Attempted Status Variable Modification
You may be trying to modify a status variable, which provides information about server operation but cannot be directly set or changed by users.
Solutions
3 solutions available1. Revert to a Previously Working Configuration easy
Undo recent configuration changes that introduced the read-only variable error.
1
Identify the recent configuration changes made to your MariaDB server. This could involve modifying the `my.cnf` or `my.ini` file, or using `SET GLOBAL` commands.
2
If you modified the configuration file, revert the specific line(s) that attempted to set the read-only variable. For example, if you added `read_only=1` and it's now causing issues, remove or comment out that line.
# read_only=1 <-- Comment out or remove this line
3
If the change was made via a `SET GLOBAL` command, restart your MariaDB server to apply the reverted configuration. The error message itself hints at this with 'Use SET %s to assign the value', implying that some variables are only settable at startup or via specific commands.
# On systemd-based systems:
sudo systemctl restart mariadb
# On older init.d systems:
sudo service mariadb restart
4
Verify that the error is resolved by attempting the operation that previously failed.
2. Use the Correct Command for Dynamic Variable Changes easy
Understand which variables can be changed dynamically and which require a server restart.
1
Examine the error message carefully. It explicitly states '%s variable '%s' is read-only. Use SET %s to assign the value'. This indicates that the variable you are trying to modify cannot be changed dynamically with `SET GLOBAL` or `SET SESSION`.
2
Consult the MariaDB documentation for the specific variable causing the error. The documentation will clarify if it's a dynamic variable (SETtable) or a static variable (requires server restart).
Example: Search for 'MariaDB [variable_name] documentation'.
3
If the variable is indeed static and cannot be changed dynamically, you must modify the MariaDB configuration file (e.g., `my.cnf` or `my.ini`) and restart the server. For example, if you were trying to set `innodb_buffer_pool_size` dynamically, you would instead add/modify it in the configuration file.
[mysqld]
innodb_buffer_pool_size = 256M
4
After modifying the configuration file, restart your MariaDB server for the changes to take effect.
# On systemd-based systems:
sudo systemctl restart mariadb
# On older init.d systems:
sudo service mariadb restart
3. Check for Replication Slave Read-Only Mode medium
Ensure the server is not in read-only mode due to replication slave status.
1
If your MariaDB instance is configured as a replication slave, it might be in read-only mode to prevent data inconsistencies. Check the value of the `read_only` system variable.
SHOW GLOBAL VARIABLES LIKE 'read_only';
2
If `read_only` is set to `1` and this is not intended for your current operation, you can temporarily disable it for the current session or globally (with caution).
# Temporarily disable for the current session:
SET SESSION read_only = 0;
# Temporarily disable globally (use with extreme caution):
SET GLOBAL read_only = 0;
3
If you need to permanently disable read-only mode for a slave, you should do so by modifying the replication configuration (e.g., `CHANGE MASTER TO ...`) or by ensuring the server is not intended to be a slave in the first place. Modifying `read_only` directly might be overwritten on a slave restart or during replication events.
4
If disabling read-only mode is a permanent change, consider updating your replication configuration or the server's role. If it's a temporary measure for administration, be aware that replication might behave unexpectedly if writes are performed on a slave.