How to Configure OpenHands MySQL Credentials

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands mysql credentials by passing database login keys into the agent workspace. You also create a restricted database user with narrow table rights for the agent. Most teams start by sharing a standard developer login with the coding agent. That broad role lets the autonomous agent alter tables or read sensitive rows by mistake. How openhands mysql credentials work in an agent workspace OpenHands runs tasks inside an isolated container sandbox. The agent writes code, runs shel

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 credentials by passing database login keys into the agent workspace. You also create a restricted database user with narrow table rights for the agent. Most teams start by sharing a standard developer login with the coding agent. That broad role lets the autonomous agent alter tables or read sensitive rows by mistake.

How openhands mysql credentials work in an agent workspace

OpenHands runs tasks inside an isolated container sandbox. The agent writes code, runs shell commands, and connects to external data stores. To query a MySQL database, the sandbox needs a host address, user name, and secret. Engineers usually pass these values into the runtime container from a secret manager.

Once inside the sandbox, the agent reads those stored values to open a database session. On the MySQL side, the server checks the user name, source host, and secret. After login succeeds, MySQL enforces the grant table rules tied to that specific account. You can scope those grants down to a single schema or specific tables.

A safe setup separates read tasks from write tasks. Teams create one read-only account for debugging and schema checks. They create a second account for migration tests inside a staging database. This split keeps the agent from dropping production tables while it inspects data structures.

Where native database roles fall short for AI agents

Native MySQL grants do a good job of deciding who can log in. They also control which tables and columns a database account can read or change. Still, native grants are static rules that apply to the whole session. They do not inspect what individual queries do while the session is active.

An AI agent with read rights on a customer table can fetch every row. Those results often hold raw emails, phone numbers, card numbers, or national IDs. When the query returns, those sensitive values flow straight into the model context window. Native MySQL roles cannot mask those fields in flight before the agent reads them.

Ephemeral Credentials + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static credentials inside a container also create a secret exposure risk. Because the agent runs shell commands, a bad prompt can print workspace secrets to logs. Also, shared database accounts hide which human user started the agent task. Database audit logs only show the generic service account name, not the engineer responsible.

Steps to harden database sessions for coding agents

Start by removing shared admin accounts from all agent workspaces. Create a dedicated MySQL user that only the coding agent uses. Restrict that account to the exact tables needed for the current task. Revoke all permissions to drop tables, change users, or alter schemas in production.

Next, set resource limits on the MySQL account to stop runaway queries. Agents often write bad joins that lock tables or use too much memory. Query timeouts and connection limits keep a confused agent from taking down the database. Rotate the stored secrets often so old keys do not linger in container logs.

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 the same MySQL user as human developers?

No, the agent should always have its own dedicated MySQL user account. Separate accounts let you set stricter query limits and tell agent actions apart in logs.

How do I stop the agent from reading sensitive customer columns?

In native MySQL, you can grant column-level select rights or query through filtered views. Data masking in flight can also rewrite emails, phone numbers, and card numbers in results.

What happens if an agent leaks database keys in its task output?

Anyone who can read the task logs can use those keys to log in. You must revoke the exposed MySQL user secret right away and issue a new key.

The query runs. The emails stay hidden.