How to Fix MySQL Error 1095 (ER_KILL_DENIED_ERROR)

Published
Length
3 min read

Luis Felipe Dias

All posts

Database users hit mysql error 1095 when they try to stop a thread owned by another user. You can fix it by running the stop command as the thread owner or an admin. When a slow query locks up a table, engineers want to stop it fast. Still, database rules block standard users from stopping processes they did not start. Understanding how thread ownership works helps your team clear stuck queries without breaking security rules. Why mysql error 1095 happens in your database MySQL tracks every

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.

Database users hit mysql error 1095 when they try to stop a thread owned by another user. You can fix it by running the stop command as the thread owner or an admin.

When a slow query locks up a table, engineers want to stop it fast. Still, database rules block standard users from stopping processes they did not start. Understanding how thread ownership works helps your team clear stuck queries without breaking security rules.

Why mysql error 1095 happens in your database

MySQL tracks every active query and session as a separate thread with a unique number. The engine assigns each thread to the specific database user account that opened the session. If your account tries to stop a thread owned by someone else, the engine blocks it.

In the official error list, this failure uses the symbol ER_KILL_DENIED_ERROR and SQLSTATE HY000. The server returns the message saying you are not the owner of that thread number. This built-in safety rule stops one app or user from breaking another app's work.

Teams often see this error when they use shared read accounts for debugging. An engineer logs in with a basic reader role and spots a slow query from the main app. Because the main app uses a different write account, the reader role cannot stop that thread.

Cloud databases also trigger this error when you try to stop system threads. Managed database hosts run background tasks for backups, health checks, and log shipping under internal admin accounts. Even your primary user account may hit this error if it targets a cloud system thread.

How to diagnose and fix the thread ownership error

First, check the active process list to see who owns the stuck thread. Look at the user column next to the thread number you want to stop. Compare that owner name with the user account you are using right now.

The safest fix is to log in as the exact user that started the stuck query. Every standard database user has the right to stop its own threads at any time. This approach clears the problem without changing any role grants or adding risky permissions.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If the stuck thread belongs to an app account, an admin may need to step in. Database admins have a special connection admin permission that lets them stop any user thread. Have an authorized admin check the query and stop the thread if it is safe.

On managed cloud databases, do not try to grant full root roles to fix this. Instead, use the vendor's built-in stored routine for stopping user queries and sessions. These cloud routines check that the target is not a system thread before stopping it.

How to prevent stuck threads without broad admin grants

Giving every engineer the permission to stop any thread creates a major risk in production. A simple typo in a thread number could drop a critical payment job or replication worker. You should keep thread admin permissions locked down to a small set of admin roles.

To prevent runaway queries, set up server-side query timeouts for your apps and users. When a read query runs past the time limit, the database stops the thread on its own. This removes the need for engineers to log in and stop slow threads by hand.

You should also mask sensitive data like emails, phone numbers, and card numbers during query checks. Data masking rewrites matched fields in results so teams can inspect queries without exposing raw personal data. Combining automatic timeouts with strict role rules keeps your database fast and secure.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.

With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

What does ER_KILL_DENIED_ERROR mean in MySQL?

It means your current database user tried to stop a thread owned by a different user. MySQL blocks this action unless your account owns the thread or has admin privileges.

Why do I get mysql error 1095 as the admin user on a cloud database?

Cloud providers reserve the highest root permissions for their own automated management tasks. You will see this error if you try to stop an internal cloud system thread.

Can I stop a single query without dropping the whole database session?

Yes, MySQL lets you stop just the running query while keeping the session open. Still, you still must own that thread or have admin rights to run the command.

The query runs. The emails stay hidden.