How to Configure OpenHands MySQL Permissions
You set up openhands mysql permissions by creating a restricted database user for the agent. Then you grant that user access to only the tables it needs to read. Engineering teams often give coding agents broad database credentials to speed up initial testing. This habit lets an automated agent alter schemas or read sensitive rows by mistake. How openhands mysql permissions work in practice OpenHands runs as an automated coding agent inside an isolated container workspace. The agent reads cod
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 set up openhands mysql permissions by creating a restricted database user for the agent. Then you grant that user access to only the tables it needs to read. Engineering teams often give coding agents broad database credentials to speed up initial testing. This habit lets an automated agent alter schemas or read sensitive rows by mistake.
How openhands mysql permissions work in practice
OpenHands runs as an automated coding agent inside an isolated container workspace. The agent reads code, runs shell scripts, and talks to external databases to fix bugs. When the agent needs data from MySQL, it reads database credentials from its local workspace. It uses a standard database client or app driver to log in to MySQL.
MySQL checks the user account and host address during the login step. After the user logs in, the database engine checks its internal grant tables. You can scope these rules to a whole database, one table, or single columns. A safe setup gives the agent read rules on test schemas and blocks drop commands.
Teams also use MySQL roles to group common rules for different agent tasks. A bug test role might only allow select statements on a few app tables. A migration test role might allow table changes inside a scratch database. You assign the right role to the agent account before a task starts.
What native database rules solve and what they miss
Native MySQL grant tables do a good job of stopping basic unauthorized access. They decide which user can log in and which tables that user can touch. If an agent tries to drop a protected table, MySQL blocks the command right away. This setup prevents an agent from wiping out a database outside its assigned scope.
Still, static database rules only check who logs in and which object they touch. They cannot check the intent or safety of a specific query in flight. An agent with read access to a customer table can still pull every row. If that table holds emails, phone numbers, or card numbers, the agent gets them all.
Static grants also leave secret keys inside the agent workspace. Because OpenHands can run shell commands, the agent can read its own local variables. A bad prompt or a logic bug could cause the agent to print those secrets. Teams also struggle to link shared database logs back to a single user or task.
MySQL Access Governance + AI Agent Permissions: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Ways to tighten agent database access
Start by creating a separate MySQL account for your coding agents. Never let an automated agent share a database user with your main app or team. Limit the host field on that MySQL user so logins only work from known networks.
Next, set query limits on the MySQL account to stop runaway agent loops. Coding agents can get stuck in retry loops and flood the database with heavy reads. MySQL lets you cap the number of queries and logins an account runs per hour. These caps protect your database server when an agent writes a slow query.
You should also avoid giving the agent direct read access to raw user tables. If the agent only needs to test query logic, point it to fake data instead. When the agent must query real tables, use database views to hide sensitive columns. Views let the agent read safe columns while keeping national IDs and card numbers out of results.
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 runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.
With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. 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
Should OpenHands use a read-only MySQL user?
Yes, start with a read-only user for most bug investigation and code review tasks. Only grant write rules in an isolated test schema when the agent must test data changes.
How do I stop an agent from reading sensitive columns in MySQL?
You can grant column-level select rules in MySQL or query through a custom database view. You can also use a tool that rewrites matched fields like emails and phone numbers in results.
Why is storing MySQL passwords in the agent workspace risky?
OpenHands executes shell commands and reads files inside its workspace to finish coding tasks. If a password sits in plain text, a bad script or log dump can expose it.
Related guides
In this post