MariaDB RBAC lets you bundle privileges into roles and assign them to users for centralized, least-privilege access control.
RBAC (Role-Based Access Control) uses roles—named privilege bundles—to simplify permission management.Instead of granting SELECT on Customers to every analyst, grant it once to a role and give users that role.
Run CREATE ROLE
for each logical job function, e.g., analysts, support, or app services.
CREATE ROLE analyst, support_agent;
Use GRANT
to attach table-level or database-level privileges to a role.
GRANT SELECT ON ecommerce.Customers TO analyst;GRANT SELECT, UPDATE(stock) ON ecommerce.Products TO support_agent;
Grant roles to users, then pick one or more as their default.
GRANT analyst TO 'jane'@'%';SET DEFAULT ROLE analyst TO 'jane'@'%';
Inside a connection, call SET ROLE
.Activate one, many, or NONE.
SET ROLE analyst;
Use REVOKE
to detach permissions or remove role membership.
REVOKE SELECT ON ecommerce.Customers FROM analyst;REVOKE analyst FROM 'jane'@'%';
1) Design roles around business tasks, not people. 2) Grant least privilege—only needed columns. 3) Use DEFAULT ROLE so users activate correct permissions automatically.4) Audit regularly with SHOW GRANTS
.
Automate role creation in migration scripts, and manage grants visually with Galaxy’s SQL editor to keep RBAC changes version-controlled and reviewable.
.
No. Roles are flat; however, you can grant one role to another to emulate nesting.
Run SELECT CURRENT_ROLE();
for the session and SHOW GRANTS FOR 'user'@'host';
for defaults.
Yes. GRANT and CREATE ROLE statements are written to the binary log and replicated like other DDL.