How to Configure Goose MySQL Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up goose mysql least privilege by creating a restricted database user. Then you grant that user read rights on specific tables and views. Many teams skip this step during their first tests. They give their AI coding agent a root account or shared developer login. Broad database rights let an AI agent drop tables or overwrite live records. A bad prompt can trigger a wide table scan on your main database. How goose mysql least privilege works in practice Goose is an autonomous developer

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 goose mysql least privilege by creating a restricted database user. Then you grant that user read rights on specific tables and views. Many teams skip this step during their first tests. They give their AI coding agent a root account or shared developer login. Broad database rights let an AI agent drop tables or overwrite live records. A bad prompt can trigger a wide table scan on your main database.

How goose mysql least privilege works in practice

Goose is an autonomous developer agent that runs tasks on a local machine. It uses extensions to talk to tools, files, and databases. When the agent needs database context, it reads local settings to log in. It uses a standard database driver to open a session with your server.

To lock this down, database admins create a dedicated account for the agent. They restrict the network host so the user only logs in from approved machines. Next, they grant read rights only on the schemas the agent needs. If the agent only checks order trends, it only gets rights on orders.

Admins also build filtered views to hide sensitive columns from the base tables. The agent queries the custom view instead of the raw customer table. You can also set database limits on queries per hour and open sessions. This stops a runaway agent loop from taking down the database server.

What native database roles solve and what they miss

Native database roles do a good job of blocking broad schema changes. A read-only user cannot drop a table or delete a row of data. Schema grants keep the agent out of payroll or billing tables. Resource limits help protect the server from basic query floods.

Still, static roles only check who logs in at the start. They do not inspect what individual queries do while they run. Once the agent has read rights on a table, it reads every row. If that table holds emails, phone numbers, or card numbers, the query returns them.

Masking rewrites matched fields in results so sensitive strings stay safe during tests. Native MySQL roles cannot mask emails or national IDs on the fly. You have to build and maintain dozens of custom views across every database. Also, static credentials sit in local files on developer laptops.

Least Privilege Principle + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

If a laptop gets lost, those saved keys put your data at risk. Rotating those static keys across a large team takes hours of manual work. Finally, database logs only show that the shared agent user ran a query. They do not tie each query back to the human who prompted the agent.

Managing schema changes and temporary write needs

Sometimes an engineer wants the agent to test a new migration or fix data. A strict read-only role blocks these tasks right away. To get around this, teams often grant write rights to the agent account. They plan to revoke those rights after the task finishes.

In reality, busy teams forget to remove those extra grants. The agent keeps write permissions for weeks without anyone noticing. A safe setup requires per-command approvals for any query that writes or alters data. That way, a human checks the exact statement before the database runs it.

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. It runs next to MySQL, RDS, or Aurora and reads the MySQL wire protocol.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails. When a rule refuses a query, MySQL returns a native error packet with your message. On the response path, hoop.dev data masking rewrites string values in returned rows that match your rules. Every query and decision is logged per resource. See the MIT-licensed project on GitHub.

Frequently asked questions

Should the Goose agent share a MySQL login with a developer?

No, the agent should always have its own separate database user. Separate users let you set strict query limits and track agent actions in logs. If an agent goes rogue, you can lock its account right away.

Can MySQL views replace dynamic data masking for AI agents?

Views can hide specific columns, but they take a lot of work to keep up. Every time a table changes, you must update the view to match it. Views also apply the exact same rules to everyone who queries them.

How do we stop an AI agent from running huge queries?

You can set MySQL server limits on execution time and connections per hour. You should also block queries that lack a row limit before they run. This keeps bad agent prompts from slowing down your main database.

The query runs. The emails stay hidden.