How to Configure Gemini CLI MySQL Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up a gemini cli mysql sandbox, link the command tool to an isolated database. You must create a restricted database user and store those login keys on your local machine. Engineering teams often use this setup so AI agents can test queries without breaking live systems. Still, teams often grant broad permissions inside the test database to move fast. When roles are too broad, a bad command from the agent can still wipe out test data. How a gemini cli mysql sandbox works The command too

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.

To set up a gemini cli mysql sandbox, link the command tool to an isolated database. You must create a restricted database user and store those login keys on your local machine. Engineering teams often use this setup so AI agents can test queries without breaking live systems. Still, teams often grant broad permissions inside the test database to move fast. When roles are too broad, a bad command from the agent can still wipe out test data.

How a gemini cli mysql sandbox works

The command tool runs in your local shell and uses your system tools to reach external data. You start by setting up a separate database instance that holds fake or stripped records. Next, you create a specific database role for the AI agent to use during its tasks. This role usually gets read permissions on most tables and write permissions on a few scratch tables.

Once the database role is ready, you put the login details into your local shell variables. The agent reads these local settings when it needs to open a database session. It then builds queries based on your prompts and sends them straight to the database server. The database checks the user login and runs any command that matches the granted role.

Many teams also use local containers to run the test database on the developer's own laptop. This keeps network traffic local and stops the agent from reaching shared company servers. When a test finishes, the developer can reset the container and start fresh for the next task. This basic flow gives the agent a safe place to try out schema changes and queries.

What native sandbox permissions solve and what they miss

A native test database with a custom role solves the first layer of risk. It decides who can log in and which tables that account can touch at rest. If the agent tries to read a restricted table, the database blocks the request right away. This setup stops an agent from touching live customer tables if you keep the servers apart.

Yet this native setup leaves a big gap open during active work. Database roles only check the user identity at login and the broad table rules. They do not inspect what each statement does while it runs in flight. If an agent has write access to a test table, it can still drop all rows.

MySQL Access Governance + AI Sandbox Environments: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Test databases also often contain real emails, phone numbers, or card numbers copied from live backups. A standard database role returns all columns in a table if the user has read permission by default. Data masking is needed to rewrite matched fields like national IDs in the query results. Without statement checks and result masking, local keys give the agent unchecked power inside the session.

Also, storing plain database keys on a laptop creates a risk if the agent reads local files. A confused agent might print those keys into a chat log or send them out. Teams need a way to check every single query and mask sensitive fields in real time.

Check MySQL queries and results on the wire

MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

Why should I use a separate database user for the AI agent?

A separate user lets you limit the agent to specific tables and actions. It also helps you track which queries came from the tool versus a human developer.

Can a read-only database role stop all AI agent mistakes?

A read-only role stops data deletion, but it does not hide sensitive fields. The agent can still pull emails or card numbers if those exist in your test data.

What happens if the agent runs a bad query in a shared test database?

If the role has write permissions, a bad query can corrupt shared test tables. This breaks work for other developers until someone restores the database from a backup.

The query runs. The emails stay hidden.