Challenge - 5 Problems
Granting Privileges Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the effect of this GRANT statement?
Consider the following MySQL command:
What privileges does 'user1' have on the
GRANT SELECT, INSERT ON employees TO 'user1'@'localhost';
What privileges does 'user1' have on the
employees database after this command?MySQL
GRANT SELECT, INSERT ON employees TO 'user1'@'localhost';
Attempts:
2 left
💡 Hint
Look at the privileges listed after GRANT.
✗ Incorrect
The GRANT statement gives 'user1' the SELECT and INSERT privileges, which means they can read and add data but cannot delete or modify existing data.
📝 Syntax
intermediate2:00remaining
Identify the syntax error in this GRANT statement
Which option correctly fixes the syntax error in the following statement?
GRANT SELECT, UPDATE employees TO 'user2'@'%';
MySQL
GRANT SELECT, UPDATE employees TO 'user2'@'%';
Attempts:
2 left
💡 Hint
Check the placement of the ON keyword.
✗ Incorrect
The correct syntax requires the ON keyword before the database or table name. Option D correctly places ON before employees.
❓ optimization
advanced2:00remaining
Optimizing privilege grants for multiple users
You want to grant SELECT privilege on the database
sales to three users: 'alice', 'bob', and 'carol', all connecting from any host. Which option is the most efficient way to do this in MySQL?Attempts:
2 left
💡 Hint
MySQL allows multiple users in one GRANT statement separated by commas.
✗ Incorrect
Option C uses a single GRANT statement listing all users separated by commas, which is more efficient than multiple separate statements.
🔧 Debug
advanced2:00remaining
Why does this GRANT statement fail?
A DBA runs this command:
But it returns an error. What is the most likely cause?
GRANT ALL PRIVILEGES ON *.* TO 'dave'@'localhost' IDENTIFIED BY 'pass123';
But it returns an error. What is the most likely cause?
Attempts:
2 left
💡 Hint
IDENTIFIED BY is used when creating users, not when granting privileges to existing users.
✗ Incorrect
In MySQL, IDENTIFIED BY is used in CREATE USER or GRANT for creating new users. Using it in GRANT for existing users causes an error.
🧠 Conceptual
expert2:00remaining
Understanding privilege scope in MySQL
If a user is granted SELECT privilege on the database
inventory and separately granted INSERT privilege on the table inventory.products, which of the following statements is true?Attempts:
2 left
💡 Hint
Database-level privileges apply to all tables in that database unless overridden by table-level privileges.
✗ Incorrect
Granting SELECT on the database allows reading from all tables. Granting INSERT on one table allows adding data only to that table.