Fixed: "ERROR 1095 (HY000): You are not owner of thread" in MySQL
KILL failed with ERROR 1095 (HY000): You are not owner of thread 183. An ordinary account can only stop its own connections, so this one needs another account's help, or a privilege that shouldn't go to an application.
What I Was Doing
I was connected as the application's account, inventory_app, on MySQL 9.7.4 in Docker, and tried to end a connection I'd found in the list:
KILL 183;
What I Expected
Query OK, and connection 183 gone.
What I Got
ERROR 1095 (HY000): You are not owner of thread 183

What I Checked
Whose connection it was. 183 was root's session, in another terminal.
The KILL page. It says: "Without CONNECTION_ADMIN or SUPER, you can kill only your own threads and statements."
Why It Happens
Ending someone else's connection rolls back their work, so MySQL treats it as an administrator's decision. Two connections of the same account count as your own, which is why an application account can end its own stuck connections and nobody else's.
The Fix
Run it from an account that's allowed to, here root:
KILL 184;
If someone needs this regularly, grant that one right, and not SUPER, to an account for that purpose:
GRANT CONNECTION_ADMIN ON *.* TO 'some_admin'@'%';
Don't give it to your application's account.
After the Fix
Query OK, 0 rows affected (0.001 sec)

Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Granting SUPER to fix it | It's deprecated, and far too broad | Use CONNECTION_ADMIN |
| Giving the right to the app's account | A compromised app can end anyone's connection | Use a separate account |
| Killing before checking what it's doing | Someone's work is rolled back | Look first |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Unknown thread id | The connection has gone | ERROR 1094 |
| It works for some connections, and not others | Those are your own account's | That's the rule |
| A managed database refuses even for its admin | Hosting providers can restrict it | Check your provider's way of killing connections |
Conclusion
ERROR 1095 means the connection isn't yours to end. Use an account with CONNECTION_ADMIN, or get its owner to finish, and keep that right away from your application.
Additional Resources
- KILL Statement — who can stop what.
- Privileges Provided by MySQL —
CONNECTION_ADMIN.
