0
0
MySQLquery~20 mins

Granting privileges in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Granting Privileges Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the effect of this GRANT statement?
Consider the following MySQL command:
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';
A'user1' can read and add new data to the employees database.
B'user1' has full control over the employees database.
C'user1' can read, add, and delete data from the employees database.
D'user1' can only read data from the employees database.
Attempts:
2 left
💡 Hint
Look at the privileges listed after GRANT.
📝 Syntax
intermediate
2: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'@'%';
AGRANT SELECT, UPDATE employees FROM 'user2'@'%';
BGRANT SELECT, UPDATE TO 'user2'@'%' ON employees;
CGRANT ON employees SELECT, UPDATE TO 'user2'@'%';
DGRANT SELECT, UPDATE ON employees TO 'user2'@'%';
Attempts:
2 left
💡 Hint
Check the placement of the ON keyword.
optimization
advanced
2: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?
AGRANT SELECT ON sales TO 'alice'@'%'; GRANT SELECT ON sales TO 'bob'@'%'; GRANT SELECT ON sales TO 'carol'@'%';
BGRANT SELECT ON sales TO ALL USERS;
CGRANT SELECT ON sales TO 'alice'@'%', 'bob'@'%', 'carol'@'%';
DGRANT SELECT ON sales TO 'alice', 'bob', 'carol';
Attempts:
2 left
💡 Hint
MySQL allows multiple users in one GRANT statement separated by commas.
🔧 Debug
advanced
2:00remaining
Why does this GRANT statement fail?
A DBA runs this command:
GRANT ALL PRIVILEGES ON *.* TO 'dave'@'localhost' IDENTIFIED BY 'pass123';

But it returns an error. What is the most likely cause?
AThe IDENTIFIED BY clause cannot be used in GRANT statements for existing users.
BThe user 'dave'@'localhost' does not exist and must be created first.
CThe syntax requires the keyword WITH after ALL PRIVILEGES.
DThe *.* syntax is invalid for granting privileges.
Attempts:
2 left
💡 Hint
IDENTIFIED BY is used when creating users, not when granting privileges to existing users.
🧠 Conceptual
expert
2: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?
AThe user can INSERT into all tables in inventory but SELECT only on inventory.products.
BThe user can SELECT from all tables in inventory and INSERT only into inventory.products.
CThe user can only SELECT and INSERT on the inventory.products table.
DThe user can SELECT and INSERT on all tables in inventory.
Attempts:
2 left
💡 Hint
Database-level privileges apply to all tables in that database unless overridden by table-level privileges.