How to Configure OpenHands MySQL Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands mysql read only access by creating a limited database user. Then you pass those read-only login keys into the agent workspace. Many teams start by giving their coding agent a shared dev account. That broad role lets the agent run bad writes or drop whole tables. A read-only setup stops the agent from changing or deleting your data. How openhands mysql read only access works OpenHands runs tasks inside its own workspace to write code and fix bugs. When the agent needs data

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 read only access by creating a limited database user. Then you pass those read-only login keys into the agent workspace. Many teams start by giving their coding agent a shared dev account. That broad role lets the agent run bad writes or drop whole tables. A read-only setup stops the agent from changing or deleting your data.

How openhands mysql read only access works

OpenHands runs tasks inside its own workspace to write code and fix bugs. When the agent needs database facts, it opens a session using local keys. It uses standard client tools in its workspace to send queries to MySQL.

To lock this down, a database admin makes a new MySQL user role. The admin grants this role permission to read tables and view schemas only. The admin leaves out permissions for altering tables, adding rows, or deleting data. Next, the team puts the new user name and password into the agent workspace. When the agent logs in, MySQL checks the role and blocks write commands. If the agent tries to change a row, the database returns an error.

What native database roles solve and what they miss

Native MySQL read permissions are a strong first step for agent safety. They stop an autonomous coding agent from wiping out production or staging tables. They also stop the agent from changing schema structures during a bug fix. Your data stays intact even if the agent writes a bad query.

Still, database roles only check who logs in and which tables they read. They do not inspect what individual queries do while they run in flight. A read-only role still lets the agent pull every row from sensitive tables by default. As a result, private emails, phone numbers, card numbers, and national IDs flow into the agent context. Those raw records can then get sent to an outside model provider. Also, you must store static database passwords inside the agent workspace. Anyone who inspects that workspace can copy those plain text keys. Finally, native roles do not stop an agent from running huge, slow queries. One bad join across big tables can still lock up your database CPU.

Auditor Read-Only Access + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Steps to harden your agent database setup

Start by scoping the MySQL role to only the schemas the agent needs. Do not grant read rights across the entire database server at once. Keep the agent away from system tables and user password hashes.

Next, set query resource limits on the MySQL user account. This keeps a confused agent from running endless loops that slow down production. You should also rotate the database password on a strict schedule. Remove old keys from the agent workspace as soon as a task ends. Turn on query logs so your team can review what the agent read. Check these logs often to spot broad table scans or odd query patterns.

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

Can OpenHands still drop tables with a read-only MySQL user?

No, MySQL blocks all drop, delete, and update commands when the role only has select rights. The database rejects the write request before any table change happens.

Does a read-only MySQL role hide private user data from the agent?

No, read-only permissions still let the agent fetch full tables with emails, phone numbers, and card numbers. You need data masking in front of the database to rewrite those fields in results.

Why are static database keys in the agent workspace a risk?

The agent has full shell rights inside its workspace and can read local files. A bad prompt could trick the agent into printing those keys in logs or chat output.

The query runs. The emails stay hidden.