How to Configure OpenHands MySQL Prevent Delete

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up an openhands mysql prevent delete rule, assign a custom database role. This role must omit delete rights on all tables used by the agent. Teams often start by giving AI coding agents full admin credentials for fast testing. Broad permissions let a confused agent wipe out critical table rows by mistake. A safer setup limits what the agent account can change from the start. How openhands mysql prevent delete works in native roles OpenHands runs tasks inside a workspace and connects to

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.

To set up an openhands mysql prevent delete rule, assign a custom database role. This role must omit delete rights on all tables used by the agent. Teams often start by giving AI coding agents full admin credentials for fast testing. Broad permissions let a confused agent wipe out critical table rows by mistake. A safer setup limits what the agent account can change from the start.

How openhands mysql prevent delete works in native roles

OpenHands runs tasks inside a workspace and connects to external data stores like MySQL. When the agent writes code or checks data, it logs in with a user key. MySQL checks the privileges tied to that specific database user before running any command.

You can create a dedicated database user just for your automated agent tasks. Instead of granting all rights, you grant only read, insert, and update rights. You leave out the delete privilege and the drop privilege on target schemas. When the agent tries to remove rows, the database engine blocks the statement right away. The database returns a permission error to the agent instead of removing data.

You can also apply this rule at the table level for finer control. For example, the agent might need to clear temporary staging tables during a test run. You can allow row removal on staging tables while blocking it on core user tables. MySQL stores these rules in its internal grant tables and checks them on every query.

What native database roles solve and what they miss

Native MySQL roles do a great job of stopping raw delete statements at the engine level. They are built into the database and add zero extra cost to your setup. If an agent runs a direct removal command, the database stops it cold. This setup decides who logs in and which basic command types they can run.

Still, static database roles cannot inspect what individual statements do in flight. An agent with update rights can still overwrite every row in a table with blank values. If a query lacks a proper filter clause, an update can ruin production data fast. Native roles also cannot require a human to approve a risky query before it runs.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static roles also do not protect private data returned in read queries. When an agent queries a customer table, it pulls back raw emails and phone numbers. Without field masking that rewrites matched fields in results, those details enter the agent prompt log. Teams also struggle to tie shared database user logs back to a specific developer task.

Steps to test your agent database restrictions

Before you let an agent work on live schemas, test your permission setup in staging. Set up the restricted MySQL user and pass those credentials to the agent workspace. Ask the agent to run a basic read query to confirm it can log in. Next, ask the agent to add a test row and update that same row.

Finally, instruct the agent to remove the test row from the protected table. Check that MySQL rejects the command and that the agent handles the error well. Review your database logs to confirm the blocked attempt appears in the audit trail. Once this check passes, review whether your team also needs controls for bad updates or raw card numbers.

Inspect every MySQL query and response in flight

Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev is an open-source proxy that runs as a sidecar for your MySQL. It reads plain queries, prepared statements, and cursors on the wire.

First, hoop.dev guardrails block banned actions before MySQL runs them. An AI Analyzer you configure can score intent, and hoop.dev data masking rewrites sensitive string columns in results. Every query and verdict goes to the resource audit trail. Find the open-source binary on GitHub.

Frequently asked questions

Can an agent still destroy data without the MySQL delete privilege?

Yes, an agent with update rights can still set important columns to null or blank values. It can also corrupt records if it runs an update query without a strict filter.

Does revoking delete rights stop the agent from dropping tables?

No, MySQL treats row deletion and table dropping as two separate privileges. You must omit both the delete right and the drop right to protect your tables.

How can teams protect private fields when OpenHands reads MySQL tables?

Native MySQL roles only block whole columns or tables, which often breaks app queries. Data masking rewrites matched fields like national IDs in results while keeping queries working.

The query runs. The emails stay hidden.