How to Configure OpenHands MariaDB Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands mariadb read only access by creating a limited database user. Then you pass those read credentials into the agent workspace. Teams often start by reusing a broad app login for speed. That shortcut lets an automated agent drop tables or alter rows by mistake. A strict read role stops write queries at the database engine level. How to set up openhands mariadb read only access First, an admin logs into the MariaDB server with full rights. The admin creates a dedicated databa

Auditor Read-Only Access + Customer Support Access to Production: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up openhands mariadb read only access by creating a limited database user. Then you pass those read credentials into the agent workspace. Teams often start by reusing a broad app login for speed. That shortcut lets an automated agent drop tables or alter rows by mistake. A strict read role stops write queries at the database engine level.

How to set up openhands mariadb read only access

First, an admin logs into the MariaDB server with full rights. The admin creates a dedicated database account just for the agent. This account gets select privileges on the target schemas or tables. You should leave out insert, update, delete, and drop permissions. You also want to restrict the host address for this database user.

Next, you prepare the runtime space where OpenHands runs its tasks. The agent uses a sandboxed container to run scripts and database tools. You pass the database host, port, username, and password as runtime variables. The agent reads these values when it starts a database client session. Every query from the agent now runs under the restricted MariaDB role.

Teams can also scope the role to specific database views instead of raw tables. Views let you join data ahead of time and omit sensitive columns. When the agent runs a select query, MariaDB checks the grant tables first. If the agent tries to change data, the database rejects the statement.

Why native database roles are only the first step

Native MariaDB privileges do a great job of blocking write commands. They ensure that a bad prompt or agent loop cannot delete production records. They also help you separate agent traffic from standard web app traffic. Database logs will show which queries came from the dedicated agent account.

Still, a static database role only checks who logs in and which tables they read. It cannot inspect what individual queries do in flight. An agent with select rights on a customer table can still read every column. If that table holds emails, phone numbers, or card numbers, the agent pulls them into context. Those raw values then get sent to the external language model provider.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Static credentials inside an agent container also create a secret management problem. Because the agent can run shell commands, it can print its own runtime variables. If a prompt tricks the agent, the raw database password can appear in task logs. Also, native roles cannot stop an agent from running a massive join that locks up CPU.

Managing query behavior and sensitive data in flight

To fix these gaps, teams need controls that work at the query level. You want to keep the database password out of the agent container completely. The agent should connect without ever holding the real target credentials. You also need a way to rewrite sensitive fields like national IDs in query results.

Row limits and query timeouts are just as important for automated agents. A human engineer might notice a slow query and cancel it right away. An AI agent might retry a failing heavy query ten times in a row. Inspecting statements before they hit the database lets you block bad queries early. You also get a clear audit log that ties every SQL statement to a specific task.

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 OpenHands still modify schema objects with a select role?

No, a MariaDB user with only select privileges cannot alter tables or drop schemas. The database engine blocks any data definition statements from that account.

Does a read role stop the agent from reading customer PII?

No, standard table grants allow the user to read all rows and columns in that table by default. Unless you use column grants, views, or data masking, the agent receives raw emails and phone numbers.

How should we handle slow queries from an automated agent?

You could set statement timeouts and connection limits on the MariaDB user account. This stops a runaway select query from eating up all database memory and CPU.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.