How to Configure MariaDB Replication User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a mariadb replication user by creating a database account with replica privileges. Then you restrict that account to the exact IP address of your replica server. Many teams rush this step and grant broad admin rights to save time. Overly broad roles let a compromised replica wipe data or read private tables on the primary host. How a mariadb replication user works in practice MariaDB moves data from a primary database to one or more replica servers. The primary server writes every

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 a mariadb replication user by creating a database account with replica privileges. Then you restrict that account to the exact IP address of your replica server. Many teams rush this step and grant broad admin rights to save time. Overly broad roles let a compromised replica wipe data or read private tables on the primary host.

How a mariadb replication user works in practice

MariaDB moves data from a primary database to one or more replica servers. The primary server writes every data change into a binary log file. The replica server logs in to the primary server using the dedicated account. It asks to read that binary log stream from a specific point. The primary server checks the role of the account before sending any data.

A proper setup gives this account only the permissions needed to read binary logs. It does not need rights to read normal tables or change schema rules. You also bind the account to a single host IP or private subnet. This stops attackers from using the account from an outside network. You should also require encrypted transport so binary log data stays private on the wire.

How to scope permissions and network rules

Start by picking a clear name for the account so auditors know its job. Generate a strong password and store it in your team secret manager. When you create the user on the primary database, specify the exact replica IP address. Never use a wildcard host symbol unless your network forces dynamic addresses. Wildcard hosts let anyone on the network try to log in with that key.

Next, grant only the binary log reader privilege to this new account. Do not add superuser rights or table read rights to this role. Sometimes an engineer uses this same account to run manual data checks or backups. Mixing human tasks with machine sync roles breaks your audit trail. Keep machine sync accounts separate from human accounts at all times.

After you grant the role, test the link from the replica server. Check the replica status output to confirm the input stream runs without errors. If the link fails, check your firewall rules and host bindings first. Do not fix a login error by granting full admin rights to the user.

User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

A scoped sync account stops a replica server from altering data on the primary host. It also limits where the replica can log in from on your network. This setup solves the machine-to-machine sync problem well. Still, database admins and developers still need direct logins to check sync health and fix drift.

Native database roles only decide who can log in at the start of a session. They cannot inspect individual queries in flight or mask sensitive fields in results. When an engineer logs in to fix a broken replica, they often use a full admin role. Static grants leave those high privileges open all day without approvals. If a query pulls rows with emails, phone numbers, or card numbers, the database sends raw text. Native roles also cannot link shared admin logins back to a single person in your identity provider.

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 sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.

First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.

Frequently asked questions

What permissions does a MariaDB replication account actually need?

The account only needs the privilege that reads binary log events from the primary server. It does not need permission to select table rows, alter schemas, or manage other users.

Can I use the root account to sync my replica servers?

You should never use the root account for database sync tasks. If someone steals the replica config file, they gain full control over your primary database.

How do I rotate the password for an active replication account?

Update the password on the primary server first, then update the replica server credentials. Restart the replica sync thread right away so it logs back in and resumes reading logs.

The query runs. The emails stay hidden.