Join our Newsletter — 33% off our NHI Course
Home› Guides› MariaDB Security Guide: Authentication Plugins, Roles, Encryption and…
Guide Data Security

MariaDB Security Guide: Authentication Plugins, Roles, Encryption and Auditing

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 18 November 2026 15 min read
On this page

MariaDB Server has its own authentication plugins, role model, encryption options and audit plugin, so a secure deployment depends on choosing how every human and application account proves who it is, what it may touch and how its activity is recorded. This guide walks through those choices for self-managed MariaDB Server, using the plugin names, statements and variables in MariaDB's documentation as of November 2026.

It is written for database administrators, platform engineers and identity teams. The emphasis is on non-human identities: the application accounts, replication users, backup agents, monitoring collectors and automation scripts that usually outnumber human database users and hold the broadest standing privileges. For the vendor-neutral foundations of database access control, read the Database Security Guide; for credential handling patterns across database engines, see the Database Credential and Access Security Guide.

This is an independent guide from NHI Mgmt Group, based on MariaDB's public documentation as of November 2026. It is not sponsored or reviewed by MariaDB. Product features change, so confirm settings against MariaDB's current documentation.

Key takeaways

  • MariaDB accounts are user@host pairs, and each can use one or more authentication plugins. Choose the plugin per account type rather than accepting one default for everything.
  • unix_socket removes the password for local administrative accounts, which is a strength, but it moves the security boundary to the operating system user and its sudo rights.
  • Prefer ed25519 over the SHA-1 based mysql_native_password for password accounts, and check that every connector your applications use supports it.
  • Give each application and automation its own account, grant through roles, and keep ALL PRIVILEGES, SUPER-class and FILE privileges away from application accounts.
  • Data at rest encryption covers InnoDB, Aria, binary and relay logs and temporary files, but not metadata or the error, general and slow query logs. Plan for those gaps.
  • Turn on the MariaDB Audit Plugin, send its output off the host, and protect the plugin from being unloaded.
  • Do not run mariadbd as root, use SELinux where available, protect log files and track MariaDB's CVE list.

The account model and where non-human identities live

A MariaDB account is a user name plus a host pattern, so app@'10.0.%' and app@localhost are two separate accounts that can hold different privileges and different authentication methods. Accounts, global privileges and authentication data are held in the system database, and the mysql.user table is where password hashes are stored. Anyone who can read it can attempt offline attacks against weak passwords, so access to the system database is itself a privileged right.

Before tuning anything, build an inventory of every account and classify it:

Account classTypical examplesRecommended authentication
Local administrationroot@localhost, DBA break-glassunix_socket mapped to named OS users
ApplicationWeb or API service accountsed25519 with a vault-issued secret, TLS required
ReplicationReplica connection usered25519, TLS required, REPLICATION SLAVE only
Backup and monitoringBackup agent, metrics exportered25519 or unix_socket on the host, narrow grants
Human named usersDevelopers, analystsPer-person accounts through roles; no shared logins

Any account whose host pattern is '%', any account with an empty user name, and any account that no current owner can name should be investigated and removed or narrowed. The Service Account Security Guide sets out ownership and lifecycle rules that apply directly to database accounts.

Authentication plugins: unix_socket, ed25519 and native passwords

unix_socket for local administration

The unix_socket plugin is installed by default in almost all MariaDB Server versions, and 'root'@'localhost' uses it by default. A package installation therefore gives root no database password; administrators connect with sudo mariadb. The plugin calls getsockopt with SO_PEERCRED to obtain the uid of the connecting process, maps it to an operating system user name, and authenticates the connection as the MariaDB account with the same name.

From MariaDB 11.6, an authentication string can name the permitted OS user explicitly, and several OS users can map to one account:

CREATE USER dba IDENTIFIED VIA unix_socket AS 'alice' OR unix_socket AS 'bob';

MariaDB's documentation lists the strengths (no password to brute-force or leak, access limited to the matching OS user, remote access usually blocked by default) and the weaknesses, which all reduce to one point: security depends on the OS user. Unlocked shared sessions, broad sudo grants, writable scripts run by that user, command injection in a web application running as that user, and weak remote access to the host all become database compromise. If you use unix_socket:

  • Never run application code as an OS user that maps to a privileged database account.
  • Restrict sudo so that only named administrators can become root or the database OS user, and log it.
  • Map administrators to named accounts rather than sharing root, so the audit log shows a person.

If you switch root back to a password with ALTER USER root@localhost IDENTIFIED VIA mysql_native_password; and SET PASSWORD, scripts that relied on passwordless access will break. MariaDB suggests a password in the [client] group of /root/.my.cnf; if you do that, treat the file as a secret with owner-only permissions.

ed25519 for password accounts

The ed25519 plugin provides password authentication based on the Ed25519 signature algorithm, the same one OpenSSH uses, as a modern alternative to the SHA-1 based mysql_native_password. MariaDB ships the library but does not install the plugin by default:

  • Install with INSTALL SONAME 'auth_ed25519';, or load at start-up with plugin_load_add = auth_ed25519 in an option file.
  • Create accounts with CREATE USER app@'10.0.1.%' IDENTIFIED VIA ed25519 USING PASSWORD('...');
  • Change passwords with ALTER USER ... IDENTIFIED VIA ed25519 USING PASSWORD('...') or SET PASSWORD.
  • To avoid plaintext secrets in scripts or history, precompute the hash with the ed25519_password function and pass it in USING '<hash>'.
  • The --ed25519 option accepts OFF, ON (the default), FORCE and FORCE_PLUS_PERMANENT; FORCE_PLUS_PERMANENT stops the plugin being uninstalled at run time.

Client support is the practical constraint. MariaDB documents support in the client_ed25519 plugin for libmysqlclient and Connector/C, and in Connector/ODBC, Connector/J and Connector/Node.js; MySqlConnector for .NET needs a separate NuGet package and an explicit install call. Test every application driver, ORM and tool before you migrate accounts. MariaDB also warns that accounts created without a password cannot log in with ed25519, and that weak passwords can still be recovered by anyone who reads mysql.user, so use long, generated secrets.

Retiring mysql_native_password

Move application accounts from mysql_native_password to ed25519 in waves: install the plugin, confirm driver support in a test environment, issue a new secret through your vault, alter the account, roll the application, then watch for failed connections. Keep a short list of accounts that must stay on the older plugin, each with an owner and an end date.

Privileges and roles

Authentication tells MariaDB which account is connecting; privileges decide what it can do. For non-human accounts, least privilege is the single largest risk reduction available.

MariaDB supports roles: named bundles of privileges created with CREATE ROLE, granted to accounts, and activated with SET ROLE or made automatic with SET DEFAULT ROLE. Use them to make privilege design reviewable:

  • Create a role per application function, such as orders_rw or reporting_ro, with grants on specific schemas or tables.
  • Grant roles to accounts rather than granting privileges directly, so a review of a handful of roles covers every account.
  • Set the role as the account's default role, so applications do not need to run SET ROLE.
  • Keep WITH GRANT OPTION and WITH ADMIN OPTION for administrators only.

Privileges that should never be granted to an application, replication or monitoring account without a written reason:

  • ALL PRIVILEGES ON *.*, which gives full administrative control.
  • FILE, which allows reading and writing files on the server host within the server's OS permissions.
  • SUPER and the finer-grained administrative privileges that replaced parts of it, which allow changing global variables, killing sessions and controlling replication.
  • CREATE USER and GRANT OPTION, which allow an account to create further accounts or pass its rights on.
  • Write access to the mysql system database.

Review grants with SHOW GRANTS FOR each account and each role on a schedule, and compare them with what the application actually uses. The Database Security Policy Template gives a policy structure for documenting these rules.

Securing application credentials

Application database passwords are among the most frequently leaked non-human credentials, because they end up in configuration files, container images, CI variables and backups. Treat them like any other high-value secret:

  • Store secrets in a secrets manager and inject them at run time, rather than committing them to configuration or baking them into images.
  • Issue one secret per account per environment. A staging credential must never work against production.
  • Rotate on a schedule and on every staff or supplier change that touched the secret. Use two accounts or a short overlap window so rotation does not cause downtime.
  • Restrict host patterns to the application's network range. An application account with host '%' accepts its stolen password from anywhere the port is reachable.
  • Protect option files. Any .my.cnf holding a password must be owner-readable only, and must not be copied into images or shared volumes.
  • Scan for leaks. Search repositories, images and build logs for MariaDB connection strings and option files.

Database dumps and snapshots contain the mysql.user table and often option files and scripts, so they carry credentials too. The Secrets in Backups and Snapshots page covers that exposure.

Encryption in transit

Password plugins protect the authentication exchange, but query results and data still cross the network. Every connection that leaves the host should use TLS:

  • Configure the server with a certificate and key issued by your internal PKI, and track their expiry in your certificate inventory.
  • Require TLS for non-human accounts at account level with REQUIRE SSL, or more strictly with REQUIRE X509 or a specific SUBJECT and ISSUER where the client presents a certificate.
  • Where every client is ready, enforce TLS server-wide with the require_secure_transport system variable.
  • Configure clients to verify the server certificate, not merely to encrypt. An application that accepts any server certificate can be redirected to an impostor.
  • Encrypt replication traffic between primary and replicas, and require TLS on the replication account.

Data at rest encryption

MariaDB's data at rest encryption needs a key management plugin installed before you enable any storage engine options. MariaDB's examples use the File Key Management plugin, file_key_management, which reads keys from a key file that MariaDB recommends you encrypt too. MariaDB also documents HashiCorp and AWS key management plugins, and notes that they support only the AES_CBC algorithm.

WhatVariable
InnoDB user tablesinnodb_encrypt_tables
InnoDB redo loginnodb_encrypt_log
InnoDB temporary tablesinnodb_encrypt_temporary_tables
Aria user tables (ROW_FORMAT=PAGE, the default)aria_encrypt_tables
Aria temporary tablesencrypt_tmp_disk_tables
Background conversion of existing InnoDB tablesinnodb_encryption_threads (default 0)

Binary and relay logs and internal temporary files can also be encrypted, which protects the replication pipeline. Note the default for innodb_encryption_threads: with no background threads, existing tables are not converted when you turn encryption on, so a database can report encryption as enabled while older tables remain in plaintext.

MariaDB is explicit about what is not encrypted: metadata, including .frm files and the data dictionary; the error log, general query log and slow query log; and the Aria control log. The general and slow query logs can contain literal data values and sometimes credentials in statements, so either keep them off in production or protect them as sensitive files. Tools such as mariadb-binlog need --read-from-remote-server to read encrypted binary logs.

The key file or key management credentials are the real secret here. A key file on the same disk as the data, readable by the same backup job, adds little. Keep keys on separate storage or in a key management service, restrict the identity that can fetch them to the database server, and back them up separately from the data. The Database Backup Security Guide covers key and backup separation.

Auditing with the MariaDB Audit Plugin

The MariaDB Audit Plugin records server activity for auditing and compliance. For each client session it can log who connected (user name and host), the queries executed, the tables accessed and server variables changed, writing to a rotating log file or to the local syslog daemon.

A practical configuration, to confirm against the plugin's options page for your version:

  • Load the plugin with INSTALL SONAME 'server_audit'; or plugin_load_add = server_audit, and set server_audit=FORCE_PLUS_PERMANENT so it cannot be uninstalled at run time.
  • Enable logging with server_audit_logging=ON.
  • Choose events with server_audit_events. A sound starting point is CONNECT,QUERY_DDL,QUERY_DCL for every account, adding QUERY_DML or TABLE for sensitive schemas or privileged accounts.
  • Send output to syslog with server_audit_output_type=syslog and forward it to your SIEM, so an attacker with database host access cannot quietly edit the trail.
  • Use server_audit_incl_users or server_audit_excl_users to focus on privileged and non-human accounts if volume is a problem, but never exclude administrators.

Detections worth building from the audit stream:

  • A non-human account connecting from a host outside its expected range, or at an unusual time.
  • Bursts of failed connections against one account, which suggest password guessing.
  • Any CREATE USER, GRANT, ALTER USER or SET PASSWORD outside a change window.
  • Application accounts running DDL, or reading tables they never normally touch.
  • Attempts to change audit or logging variables, or to uninstall plugins.

Protect the log files themselves: MariaDB recommends strict OS file permissions, automated rotation, encryption at rest and TLS in transit for logs.

Server and host hardening

  • Do not run mariadbd as root. MariaDB documents how to run it under a dedicated, less privileged OS account.
  • Use SELinux where your distribution supports it, with the MariaDB policy, so a compromised server process is confined.
  • Remove defaults after installation: anonymous accounts, test databases and remote root access. The mariadb-secure-installation script exists for this.
  • Bind to the right interface. Set bind_address to a private interface, and use host firewalls so only application and administration networks reach the port.
  • Restrict file import and export with secure_file_priv, and keep local_infile off unless a workload needs it.
  • Track vulnerabilities and patch. MariaDB publishes a list of CVEs fixed in each release. Stay on a supported release series and apply maintenance releases promptly.

For framework mapping, these controls align with NIST SP 800-53 AC-6 (least privilege), IA-5 (authenticator management), SC-8 (transmission confidentiality and integrity), SC-28 (protection of information at rest) and AU-2 (event logging).

Common failure patterns

  • One application account for everything. Every service shares a single account with ALL PRIVILEGES, so one leaked secret exposes every schema and the audit log cannot tell services apart.
  • Wildcard host patterns. Application accounts defined with host '%' accept their password from any network that can reach the port.
  • unix_socket with weak OS controls. Root uses socket authentication, but a web application or cron job runs as an OS user that maps to a privileged account.
  • Native password hashes left in place. Accounts stay on mysql_native_password because nobody tested the drivers, and dumps of mysql.user are exposed to offline attack.
  • Encryption enabled but incomplete. Encryption variables are on, but no background threads convert existing tables, and query logs on the same disk hold plaintext data.
  • Key file next to the data. The key file sits on the same volume and in the same backup set as the encrypted tablespaces.
  • Audit plugin missing or local only. No audit trail exists, or it is a local file the attacker can edit.
  • Secrets in option files and images. Passwords in .my.cnf or environment files are copied into container images and repositories.

Practitioner checklist

  • Every account is inventoried, classified as human or non-human, and has a named owner.
  • No anonymous accounts, test databases or remote root logins remain.
  • Local administration uses unix_socket mapped to named OS users, with restricted and logged sudo.
  • Password accounts use ed25519 with generated secrets from a secrets manager; remaining mysql_native_password accounts have an end date.
  • Each application, replica, backup agent and monitor has its own account with a narrow host pattern.
  • Privileges are granted through roles, set as default roles, and reviewed with SHOW GRANTS on a schedule.
  • No application account holds ALL PRIVILEGES, FILE, SUPER-class, CREATE USER or GRANT OPTION.
  • TLS is required for non-human accounts and replication, and clients verify the server certificate.
  • Data at rest encryption covers tables, redo log, binary logs and temporary files, with existing tables converted and keys stored apart from data.
  • The audit plugin is loaded as permanent, logs connections, DDL and DCL, and forwards to the SIEM.
  • mariadbd runs as a non-root user, SELinux is enforcing, and the server is on a supported, patched release.

Standards and references

Related NHI Mgmt Group resources: Database Security Guide · Database Credential and Access Security Guide · Database Backup Security Guide · Service Account Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.