Challenge - 5 Problems
Role Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Check user privileges with roles
Given a MySQL database with roles assigned to users, what will be the output of the following query?
SELECT user, host, GROUP_CONCAT(DISTINCT role SEPARATOR ', ') AS roles FROM mysql.role_edges GROUP BY user, host;MySQL
SELECT user, host, GROUP_CONCAT(DISTINCT role SEPARATOR ', ') AS roles FROM mysql.role_edges GROUP BY user, host;
Attempts:
2 left
💡 Hint
GROUP_CONCAT aggregates values per group; DISTINCT avoids duplicates.
✗ Incorrect
The query groups rows by user and host, then concatenates distinct roles for each user-host pair, showing their assigned roles.
🧠 Conceptual
intermediate1:30remaining
Understanding role inheritance in MySQL
In MySQL role-based access control, if role A is granted to role B, and role B is granted to user U, which of the following is true?
Attempts:
2 left
💡 Hint
Think about how roles can be nested in MySQL.
✗ Incorrect
MySQL supports role inheritance, so granting role A to role B and role B to user U means U inherits privileges from both roles.
📝 Syntax
advanced2:00remaining
Identify the correct syntax to create a role and grant privileges
Which of the following MySQL statements correctly creates a role named 'report_viewer' and grants SELECT privilege on the 'sales' database to it?
Attempts:
2 left
💡 Hint
Role names are identifiers, not strings; privileges must specify database and tables.
✗ Incorrect
In MySQL, role names are identifiers without quotes; privileges must specify database and tables with .* suffix.
❓ optimization
advanced2:30remaining
Optimizing role privilege checks
You want to quickly check all privileges a user has through roles in MySQL. Which query is the most efficient to get all privileges for user 'alice' including inherited roles?
Attempts:
2 left
💡 Hint
Consider roles assigned to the user and privileges granted to those roles.
✗ Incorrect
Option A checks privileges granted directly to the user and to roles assigned to the user, covering inheritance efficiently.
🔧 Debug
expert3:00remaining
Debugging role assignment failure
A DBA runs:
But receives an error. What is the cause?
GRANT 'data_analyst' TO 'bob'@'localhost';But receives an error. What is the cause?
Attempts:
2 left
💡 Hint
Check syntax for role names in GRANT statements.
✗ Incorrect
In MySQL, role names are identifiers and should not be quoted in GRANT statements; quoting causes syntax error.