MySQL 8.0 introduced roles, which are named collections of privileges. Instead of granting the same set of privileges to multiple users individually, you define a role once and assign it to users. This simplifies privilege management and reduces errors.
Creating and Using Roles
Create a role with CREATE ROLE, grant privileges to the role, then grant the role to users. Users must activate roles (or have them set as default) to benefit from them.
Benefits of Roles
- Centralized privilege management — change a role and all users inherit the update
- Easier auditing — review role permissions in one place
- Supports role hierarchies (granting roles to roles)
- Separation of duties — DBA, developer, and read-only roles