<p>MySQL raises error 1621 when a SET statement tries to modify a system variable that is marked read-only.</p>
<p>MySQL Error 1621 ER_VARIABLE_IS_READONLY occurs when a statement tries to change a read-only system variable. Remove the assignment or use SET PERSIST or an updateable alias to resolve the issue.</p>
%s variable '%s' is read-only. Use SET %s to assign the
The server returns ER_VARIABLE_IS_READONLY when a user issues SET or ALTER INSTANCE for a variable defined as read-only at the requested scope. MySQL blocks the change to protect internal consistency.
The message format is: %s variable '%s' is read-only. Use SET %s to assign the value. The placeholders show the scope, variable name, and valid clause.
The error is most common during session initialization scripts, configuration migrations, or automated deployments that include blanket SET GLOBAL statements. It also surfaces in stored procedures or ORM-generated SQL that manipulates server variables.
Attempting to change variables like 'version', 'innodb_version', or 'hostname' will always fail because they are immutable while the server is running.
Misunderstanding between SESSION and GLOBAL scopes triggers the error when a variable is writable only at startup but not at runtime.
First, identify the variable. Check the read_only column in performance_schema.system_variables or run SHOW VARIABLES LIKE 'name'.
If MySQL offers a writable companion variable or SET PERSIST support, switch to that method. Otherwise, remove the statement or place the value in my.cnf and restart.
CICD pipelines often include SET GLOBAL statements for every parameter. Trim the list to exclude read-only entries.
Some ORMs enable ANSI mode by toggling sql_mode. Use SET SESSION sql_mode instead of SET GLOBAL when running as a non-admin user.
Verify variable mutability with SHOW VARIABLES or the INFORMATION_SCHEMA before issuing SET commands.
Store permanent configuration inside my.cnf and reserve runtime changes for documented dynamic variables only.
Error 1238 variable does not exist - occurs when the name is misspelled. Correct the identifier.
Error 1229 variable is read-only when SUPER privilege is missing. Grant proper privileges or use SESSION scope.
Variables such as version and innodb_version are informational and cannot be changed at runtime.
Using SET GLOBAL on a parameter that is only dynamic at SESSION scope or vice-versa produces the read-only error.
Without SUPER or SYSTEM_VARIABLES_ADMIN privileges, MySQL treats some dynamic variables as read-only to the caller.
Scripts that iterate over parameter lists often include immutable variables that trigger the error during deployment.
Raised when a variable is read-only due to insufficient privileges. Grant SYSTEM_VARIABLES_ADMIN to resolve.
Occurs when the variable name does not exist. Check spelling.
Thrown when referencing a variable removed in the current server version. Review release notes.
No. Read-only variables are locked by design to ensure server stability. Only a restart with a new my.cnf value will take effect.
No. SET PERSIST only applies to variables marked dynamic. Attempting it on immutable variables still raises error 1621.
For GLOBAL scope, the account must have SUPER or SYSTEM_VARIABLES_ADMIN. SESSION scope typically needs no special privilege.
Galaxy highlights read-only variables in autocomplete and warns before execution, letting engineers catch the issue inside the editor.