How to Fix MySQL Error 4159 (ER_CANT_SET_PERSISTED)

Published
Length
3 min read

Luis Felipe Dias

All posts

You see mysql error 4159 when the server fails to set persisted options. You fix this error by checking file rights, disk space, and valid option values. The official symbol for this failure is ER_CANT_SET_PERSISTED, which uses SQLSTATE HY000. The server returns the plain message: Failed to set persisted options. When this happens, the database cannot apply or save your runtime changes across restarts. Database teams must find the root cause fast to keep cluster nodes in sync. What causes mys

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You see mysql error 4159 when the server fails to set persisted options. You fix this error by checking file rights, disk space, and valid option values.

The official symbol for this failure is ER_CANT_SET_PERSISTED, which uses SQLSTATE HY000. The server returns the plain message: Failed to set persisted options. When this happens, the database cannot apply or save your runtime changes across restarts. Database teams must find the root cause fast to keep cluster nodes in sync.

What causes mysql error 4159 in your database

MySQL lets admins save system changes to a special file in the data folder. The engine reads this file during startup to restore your chosen settings. If the engine cannot write to this file, or cannot load the saved values, it throws mysql error 4159.

File permission issues are the most common cause of this failure. The operating system user that runs the database process needs write access to the data folder. If an admin changes file ownership on the host, the database loses write access. A read-only disk mount or a full storage volume also blocks the write step.

Invalid option values also trigger this specific error during startup or runtime. Sometimes a saved setting conflicts with a new limit after a version upgrade. Other times, someone edits the persisted settings file by hand and breaks the format. When the parser hits bad text or an out-of-range value, it stops and logs the error.

Plugin load order can cause this issue as well. If a persisted setting belongs to a plugin that is not active yet, the server cannot apply it. The engine rejects the setting and raises the HY000 general error code.

How to check the logs and find the root cause

Start your check by reading the main database error log. The client message only tells you that setting persisted options failed. The server error log shows the exact system variable or file error that caused the crash.

Next, check the storage health on the database host. Make sure the disk partition has free space and free file nodes. Verify that the storage volume is mounted in read-write mode, not read-only mode.

MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Then, inspect the ownership of the persisted settings file inside the data directory. Confirm that the dedicated database system user owns both the folder and the file. Do not give full read and write permissions to all users on the host. Keep file rights strict so only the database service account can change the file.

If the file permissions and disk space look fine, inspect the persisted values. Look for variables that belong to unloaded plugins or removed features. Check the active persisted variables view inside the database to spot bad entries.

How to fix persisted option failures safely in production

Once you find the broken variable or file lock, apply a targeted fix. If file ownership is wrong, restore ownership to the database service user on the host. Never run the database process as the root operating system user to bypass file errors.

If a specific persisted variable has a bad value, clear that single setting. You can reset the broken persisted variable using a standard admin query. This removes the bad entry from the file without wiping out other saved settings. Avoid deleting the entire persisted settings file on a live server unless the node cannot start.

In a managed cloud database, local file changes are often blocked by design. Cloud providers manage settings through their own control planes and parameter groups. If you get this error on a cloud instance, move the setting to the provider control panel. Do not grant superuser rights to regular app roles to force runtime changes.

Keep production access tight when you run admin fixes. Limit persisted variable changes to senior database admins who understand the cluster setup. Track every admin command in an audit log so the team knows what changed. You can also turn on data masking to rewrite emails and card numbers in query results during checks.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

What does ER_CANT_SET_PERSISTED mean in MySQL?

ER_CANT_SET_PERSISTED is the official symbol for error code 4159 with SQLSTATE HY000. It means the database server failed to save or apply persisted system options.

Can a full disk cause mysql error 4159?

Yes, a full disk stops the engine from writing changes to the data folder. Freeing up disk space on the host lets the server save persisted options again.

How do I fix a corrupted persisted settings file on startup?

Check the server error log to find which saved option is blocking the startup. Fix the bad entry in the file or reset the variable once the server starts.

The query runs. The emails stay hidden.