How to Configure OpenHands MySQL Connect

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands mysql connect by giving the agent container a database user and host address. The agent then uses standard client drivers to log in and run SQL queries. Teams often start by handing the agent a broad admin account to speed up testing. When roles are too broad, an automated agent can change schemas or read private customer records by mistake. How openhands mysql connect works in practice OpenHands runs tasks inside a sandbox container that acts like a developer workspace.

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 connect by giving the agent container a database user and host address. The agent then uses standard client drivers to log in and run SQL queries. Teams often start by handing the agent a broad admin account to speed up testing. When roles are too broad, an automated agent can change schemas or read private customer records by mistake.

How openhands mysql connect works in practice

OpenHands runs tasks inside a sandbox container that acts like a developer workspace. When a task requires data checks, the agent opens a TCP session to the MySQL server. You pass the host, port, username, and password into the runtime workspace as secret variables.

The MySQL server checks those login details against its internal user grant tables. It looks at the user name and the client host IP address to verify identity. Next, the server checks which database permissions apply to that specific account. You can scope these permissions down to single schemas, tables, or even specific columns.

Once the login succeeds, the agent sends SQL queries to inspect tables or fix app bugs. The database runs each query that matches the granted role and returns the raw rows. The agent reads these results and puts them into its prompt history to plan the next step.

What native database roles solve and what they miss

Native MySQL roles do a good job of controlling who can log in. You can create a read-only user so the agent cannot drop tables or delete rows. You can also block access to whole schemas that hold billing or payroll data. These controls stop basic mistakes at the database boundary.

Still, static database roles only check permissions at the table or column level. They do not inspect what individual queries do in flight or how many rows return. If the agent needs to check a user table, a read role returns every selected field. That response often includes raw emails, phone numbers, card numbers, or national IDs.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static secrets inside the agent sandbox create another operational risk for your team. Because the agent can run shell scripts, a bad prompt might print workspace secrets to logs. Also, standard database logs only show the shared agent account name on every query. You lose track of which engineer or task triggered a specific database change.

Steps to tighten agent database sessions

Start by creating a dedicated MySQL account just for your automated agent tasks. Grant select permissions only on the specific tables needed for the current sprint. Turn on SSL encryption so login details and query results do not travel in plain text.

Next, set server resource limits on that account to cap queries per hour. This stops a stuck agent loop from overwhelming your database CPU or memory. Finally, pair native roles with runtime controls that mask matched fields like emails and card numbers in 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 an AI coding agent use a shared admin database account?

No, an admin account lets the agent drop tables or read every schema on the server. Always create a separate user with the minimum permissions required for the task.

How can teams protect sensitive data during agent queries?

Native roles can block whole columns, while runtime masking rewrites emails, phone numbers, and card numbers in results. This lets the agent test app logic with realistic row shapes while keeping raw values hidden.

Why do static database passwords in agent containers cause risk?

Agents execute arbitrary code and shell commands inside their runtime workspace to solve coding tasks. If a prompt reads the local secret store, it can leak long-lived database passwords into logs.

The query runs. The emails stay hidden.