How to Configure Claude Code MariaDB Read Only Access
You set up claude code mariadb read only access with a restricted database user. Then you pass that user's login string to a Model Context Protocol server. Teams often connect AI coding tools to databases so the agent can check schemas. If teams use a shared admin login, the agent can change or delete rows. A dedicated read-only account stops the agent from running write queries on your tables. How claude code mariadb read only access works in practice Claude Code reaches outside tools and da
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 claude code mariadb read only access with a restricted database user. Then you pass that user's login string to a Model Context Protocol server. Teams often connect AI coding tools to databases so the agent can check schemas. If teams use a shared admin login, the agent can change or delete rows. A dedicated read-only account stops the agent from running write queries on your tables.
How claude code mariadb read only access works in practice
Claude Code reaches outside tools and databases through the Model Context Protocol, or MCP. MCP servers give Claude Code a bridge to your tools, databases, and APIs. Querying databases is a common use case in the vendor docs. The docs show an example using the DBHub MCP server with a database string. They tell you to put a read-only database user in that login string. This makes sure the queries Claude runs cannot change your stored data. The docs also tell you to trust each MCP server before you use it.
Claude Code can also reach a MariaDB database through its built-in Bash tool. The Bash tool runs shell commands on the local machine. In Manual mode, the Bash tool asks for your approval before it runs commands. Only a small built-in list of safe local commands runs without approval. When an engineer approves a database client command, the shell uses the local login. If that local login is a read-only MariaDB user, the database blocks any writes.
What native read-only roles solve and what they miss
A read-only MariaDB user is a strong first step for any team. The database engine checks the user role at login and before each query runs. It blocks statements that insert, update, or drop tables. Even if a prompt goes wrong, the agent cannot alter or wipe your data.
Still, a database role only decides who logs in and which tables they read. It does not inspect what individual select statements do while they run in flight. A read-only user can still read every column inside an allowed table by default. If a table holds customer emails, phone numbers, card numbers, or national IDs, queries return them. The raw values go right into the agent context and out to the model. Data masking is needed to rewrite matched fields in query results before they return.
Auditor Read-Only Access + Claude Code Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static database strings also create a key sharing problem across developer laptops. To use an MCP server, engineers must store the database login on their machines. Every laptop holds a live database key that stays valid until someone rotates it. Database logs also show every query coming from that one shared read-only role. You cannot tell which engineer or which agent session ran a heavy select query. A bad query from an agent can still lock tables or slow down production.
Why query-level controls matter for AI agents
AI coding agents run queries much faster than human engineers do during debug work. An agent might scan five large tables in seconds to answer one layout question. Native database roles cannot pause one heavy query to ask a human for approval. They also cannot tie a database query back to a specific team member's identity. Teams need controls that check each statement and mask sensitive fields 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 sits inline in the wire protocol beside the database as a sidecar for your MySQL. On every production query an agent or engineer sends, hoop.dev decides to pass, mask, block, or escalate it for human review.
With hoop.dev MySQL support, guardrails refuse bad queries before they run or hold risky calls for approval, while 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
How does Claude Code connect to a MariaDB database?
Claude Code reaches databases through Model Context Protocol servers like DBHub or through its Bash tool. Both methods use the database login details stored on the user's machine.
Does a read-only MariaDB user hide sensitive customer data from Claude Code?
No, a read-only user can still read all columns in an allowed table by default. Without field masking, queries return raw emails, phone numbers, card numbers, and national IDs.
Does the Claude Code Bash tool run database queries on its own?
In Manual mode, the Bash tool requires user approval before running database client commands. It only runs a small built-in set of local read commands without asking first.
Related guides
In this post