How to Configure Dify MariaDB Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up dify mariadb read only access by creating a dedicated database user. Then you grant that user select rights and add the credentials to your app. Most teams start by sharing a single admin account during early testing. That broad role lets an AI workflow change or delete rows by mistake. A strict read role stops unwanted writes before they hit your tables. How dify mariadb read only access works in your setup First, an admin logs in to the database server to make a new user. This us

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 dify mariadb read only access by creating a dedicated database user. Then you grant that user select rights and add the credentials to your app. Most teams start by sharing a single admin account during early testing. That broad role lets an AI workflow change or delete rows by mistake. A strict read role stops unwanted writes before they hit your tables.

How dify mariadb read only access works in your setup

First, an admin logs in to the database server to make a new user. This user needs a strong password and a clear host limit. You set the host rule so only your AI app server can log in. Next, the admin gives this user select rights on specific tables or views. You should avoid giving select rights on the whole database if possible. Some tables hold secret keys or user passwords that the AI does not need.

Database views help you narrow down what the AI tool can read. You can build a view that joins safe columns and leaves out private ones. Then you grant the database user select rights on that view alone. After the database role is ready, you open your AI app settings. You enter the host, port, user name, and password into the tool block. The AI agent now uses this restricted account for every query it runs.

What native database roles solve and what they miss

A native read role solves the problem of accidental data changes. The database engine blocks any insert, update, or delete statement from that user. It also blocks schema changes like dropping a table or adding a column. This setup decides who can log in and which tables they can read. It acts as a strong first line of defense for your stored data.

Still, static database roles leave a big gap during live operation. A read role cannot tell what an individual query does in flight. The AI agent might run a massive join that locks up your CPU. It can also pull thousands of rows filled with sensitive customer details. If a table holds emails, phone numbers, or card numbers, select rights return them. The database sends those raw values straight into the AI model prompt. Also, static passwords sit inside your app settings for months. If someone leaks that password, anyone on the network can read your tables. Database logs also show every query coming from the same shared app user. You cannot see which team member or workflow triggered a slow or risky read.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing query limits and sensitive fields in flight

To close these gaps, teams need controls that check queries as they run. You should set time limits and row limits on every read session. If a generated query takes too long, the system should stop it fast. This keeps a bad AI prompt from hurting your main production workload. You also need a way to handle private data inside allowed tables.

Data masking rewrites matched fields in results before they reach the AI app. When a query fetches emails, phone numbers, or national IDs, masking swaps those values. The workflow still gets the rest of the row to answer the user question. Finally, linking each query to a real user identity improves your audit logs. You can trace every database read back to the exact person who asked.

Inspect every MySQL query and response in flight

Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev is an open-source proxy that runs as a sidecar for your MySQL. It reads plain queries, prepared statements, and cursors on the wire.

First, hoop.dev guardrails block banned actions before MySQL runs them. An AI Analyzer you configure can score intent, and hoop.dev data masking rewrites sensitive string columns in results. Every query and verdict goes to the resource audit trail. Find the open-source binary on GitHub.

Frequently asked questions

Can an AI agent still slow down MariaDB with read only rights?

Yes, a bad select query can still scan millions of rows and use memory. You should set query timeouts and row limits on the database user.

Should I give the AI user access to full tables or views?

Views are safer when a table mixes public facts with private user fields. A view lets you expose only the safe columns to the database role.

How do I stop raw customer data from reaching the language model?

Database roles only allow or block whole tables or columns at rest. You need query masking in flight to rewrite emails or card numbers in results.

The query runs. The emails stay hidden.