How to Configure Haystack MariaDB Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up haystack mariadb read only access by creating a limited database user. Then you pass that user key into your Haystack database component. Many teams start by reusing a general app role during early tests. If that role has write rights, an AI agent can change or drop tables. A strict read role stops those bad writes before they happen. How haystack mariadb read only access works in native setups A Haystack pipeline uses a retriever or query component to talk to MariaDB. The componen

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 haystack mariadb read only access by creating a limited database user. Then you pass that user key into your Haystack database component. Many teams start by reusing a general app role during early tests. If that role has write rights, an AI agent can change or drop tables. A strict read role stops those bad writes before they happen.

How haystack mariadb read only access works in native setups

A Haystack pipeline uses a retriever or query component to talk to MariaDB. The component takes a question from a user or a language model. It turns that text into a SQL query and sends it to MariaDB. MariaDB checks the user role before it runs any query.

To lock this down, an admin creates a dedicated account in MariaDB. The admin grants only select permissions on specific tables or views to that account. You do not grant insert, update, delete, or drop rights to this role. You also restrict the host network range so only the Haystack app can log in.

Next, the team stores the database user name and password in a secret store. When the Haystack app starts up, it reads those secrets into memory. The pipeline uses that account to open a session with the MariaDB server. If the language model writes an update or drop query, MariaDB blocks the command.

Where native database roles fall short for AI pipelines

Native MariaDB permissions do a great job of blocking data changes and table drops. They decide who can log in and which tables that account can read. Still, static database roles cannot check what individual queries do in flight. Once a role has select access to a table, it can read every column by default.

Customer tables often hold private data like emails, phone numbers, card numbers, and national IDs. A read role lets the Haystack pipeline pull all of those columns into memory. The language model then receives those raw fields inside its prompt context. Native table grants cannot mask those fields in query results on the fly.

Shared service accounts also make auditing hard for security teams. Every query from the Haystack app shows up under the same database user name. Database logs cannot tell which human user or AI agent triggered a specific query. Also, a bad model prompt can write a huge join that slows the server.

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.

How to tighten MariaDB controls for Haystack agents

Teams can reduce risk by creating clean database views for the AI pipeline. A view can leave out sensitive columns or hash them before Haystack reads them. You then grant the Haystack MariaDB user select rights only on those safe views. This keeps raw emails and card numbers out of the main query path.

You should also set resource limits on the MariaDB account used by Haystack. MariaDB lets admins cap the number of queries and connections per hour. You can also set a max query time so slow selects stop right away. These limits keep a runaway AI loop from locking up production tables.

Even with views and limits, teams still have to manage static database passwords. Updating views every time the schema changes takes ongoing work from the data team. Most engineering teams want a way to mask sensitive fields without building extra views.

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 runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.

With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. 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

Can a Haystack pipeline still slow down MariaDB with read only access?

Yes, a read role can still run heavy joins or full table scans. You should set query timeouts and connection limits on the MariaDB user account.

Do MariaDB read roles hide emails or card numbers from Haystack?

No, standard select permissions return all data inside the permitted tables or columns. To hide emails or card numbers, you need views or data masking in flight.

Should multiple Haystack apps share the same MariaDB read user?

No, sharing one account makes it hard to track which pipeline ran a query. Give each Haystack app its own database role or link queries to user identity.

The query runs. The emails stay hidden.