How to Configure Amazon Q MySQL Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up amazon q mysql read only access by creating a restricted database user. Then you give the AI assistant credentials that only allow select queries. Teams often start by handing their coding assistant a standard developer database key. That shortcut lets the AI agent run any query that the human developer can run. When permissions are too broad, a bad prompt can alter rows or drop tables. Limiting the database account to read operations stops the assistant from changing live data. How

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 amazon q mysql read only access by creating a restricted database user. Then you give the AI assistant credentials that only allow select queries. Teams often start by handing their coding assistant a standard developer database key. That shortcut lets the AI agent run any query that the human developer can run. When permissions are too broad, a bad prompt can alter rows or drop tables. Limiting the database account to read operations stops the assistant from changing live data.

How amazon q mysql read only access works in practice

Amazon Q Developer runs inside your code editor or command line tool. It helps engineers write code, debug errors, and inspect data schemas. When the assistant needs database context, it uses local tools or external server integrations. Those tools log in to MySQL using a database username and password. MySQL checks the account permissions right when the session starts.

To keep the setup safe, database admins create a dedicated role for the assistant. This role grants permission to read tables and views in specific schemas. Admins leave out permissions that insert, update, delete, or change table structures. Next, the admin assigns this read role to a dedicated MySQL user account. The developer puts those credentials into the local setup that the assistant uses. Every query from the AI tool then runs under MySQL privilege checks. If the assistant tries to write data, the database blocks the query right away.

What native database roles solve and what they miss

Native MySQL roles do a good job of stopping accidental writes and schema drops. They enforce a hard wall between reading data and changing data at the storage engine. This setup is the right first step for any team using AI coding tools. Still, database roles only decide who can log in and which tables they can read. They do not inspect what individual queries do in flight.

A read role still lets the assistant pull every column in an allowed table by default. If a customer table holds emails, phone numbers, or card numbers, the query returns them. Those raw values then flow into the AI prompt context and external model servers. Native read roles also cannot stop an assistant from running a huge unindexed join. One bad select query can lock up CPU and slow down production apps. Also, shared read credentials make audit logs hard to read. The database log shows the shared bot user instead of the person who asked.

Auditor Read-Only Access + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Steps to tighten database rules for AI coding tools

Start by scoping the read role to only the tables the team needs for work. Never grant read rights across every schema on the server by default. Leave out auth tables, billing records, and secret store tables from the allowed list. Use database views to expose safe columns while hiding sensitive fields from the read user.

You should also set resource limits on the MySQL account used by the assistant. MySQL lets admins cap how many queries or logins an account can run per hour. Setting query timeouts helps kill slow select statements before they hurt the main database. Finally, rotate the database password often and avoid storing plain text keys in code repos. Even with these steps, static database users remain hard to manage across a growing team. Admins still have to update grants by hand whenever schema needs change.

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

Can a MySQL read role stop an AI assistant from seeing sensitive columns?

A basic table grant lets the user read every column in that table by default. You must set up column grants, build restricted views, or mask fields in results.

Why is a read query from an AI tool still a risk to production?

A read query can scan millions of rows without an index and spike server memory. It can also pull emails, phone numbers, or national IDs into external AI logs.

Should developers share one MySQL read account for their AI assistants?

Sharing one account hides who ran which query in the MySQL audit logs. Tying database activity to individual developer identities makes security reviews much clearer.

The query runs. The emails stay hidden.