How to Configure Claude Code MariaDB Permissions
You set up claude code mariadb permissions by creating a read-only database user. Then you pass that user in the Model Context Protocol server link. Many teams start by reusing an app account or a developer login. Broad database roles create big risks when an AI agent writes and runs SQL. One bad prompt can change rows, drop tables, or pull private customer records. A tight role stops the agent from changing data while it checks schemas. How claude code mariadb permissions work Claude Code re
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 permissions by creating a read-only database user. Then you pass that user in the Model Context Protocol server link. Many teams start by reusing an app account or a developer login. Broad database roles create big risks when an AI agent writes and runs SQL. One bad prompt can change rows, drop tables, or pull private customer records. A tight role stops the agent from changing data while it checks schemas.
How claude code mariadb permissions work
Claude Code reaches external databases in two main ways. First, it connects through Model Context Protocol servers, which link the agent to databases. The official docs urge teams to use a read-only database user in that link. That way, the queries the agent runs cannot modify your stored data. You should also verify that you trust each MCP server before you use it. Second, the agent can run shell commands through its built-in Bash tool. In Manual mode, the Bash tool asks for human approval before running most commands. Only a small built-in set of safe read commands runs without a prompt. Database client calls through the shell ask for approval before they run.
On the MariaDB side, you control access with standard user accounts and grants. You create a dedicated account just for the coding agent. Then you grant that user select rights on the specific schemas it needs. You leave out insert, update, delete, and drop rights across the whole server. When the MCP server starts, it logs in with those restricted credentials. Every query the agent sends runs inside the bounds of that MariaDB role. If the agent tries to write data, the database engine blocks the command.
What native database roles solve and what they miss
Native MariaDB roles solve the basic problem of who can log in. They also draw a hard line between reading tables and changing tables. A read-only grant stops accidental deletes and schema changes from an AI prompt. For local test databases with fake data, a read-only account is often enough.
Still, database grants do not check what individual queries do in flight. A read-only user can still read every column in an allowed table by default. If a table holds emails, phone numbers, card numbers, or national IDs, queries return them. Those sensitive values then flow straight into the model context and chat logs. Also, standard roles cannot stop an agent from running a massive join query. A bad read query can still lock tables or slow down a busy server. Finally, shared database logins make audit logs hard to read. The database log shows the shared MCP user, not the developer who prompted it. Teams also must hand out static passwords onto developer laptops to run local servers.
Claude Code Security + AI Agent Permissions: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Steps to tighten agent database access
Start by creating a separate MariaDB account with only select privileges on non-sensitive tables. Never share your main app user or root account with an AI coding tool. Next, limit which schemas and views that read-only role can reach. If a table holds private keys or secrets, keep it out of the grant. Keep Claude Code in Manual mode so you check shell commands before they run. Review every MCP server package before you add it to your local setup. When your team connects to real data, look for controls that work per query. Masking rules that rewrite matched fields in results help protect emails and card numbers. Tying each query to an individual developer identity also keeps your audit trail clean.
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?
It connects through a Model Context Protocol server or by running shell database clients. Both paths use the database login details you set up on your machine.
Should I give an AI coding agent write permissions in MariaDB?
No, vendor docs advise using a read-only database user in your server string. This ensures the queries the agent runs cannot modify or delete your data.
Do read-only MariaDB roles protect sensitive customer columns?
No, a standard select grant lets the user read all columns in a table by default. You need column grants, views, or query masking to hide emails and card numbers.
Related guides
In this post