0
0
MySQLquery~20 mins

Revoking privileges in MySQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Privilege Revoker
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 REVOKE command?
Consider the following command executed on a MySQL server:

REVOKE SELECT ON employees FROM 'user1'@'localhost';

What is the result of this command?
MySQL
REVOKE SELECT ON employees FROM 'user1'@'localhost';
AUser 'user1' gains SELECT privilege on the employees table.
BUser 'user1' loses all privileges on the employees database.
CUser 'user1' loses the ability to connect to the server.
DUser 'user1' loses the SELECT privilege on the employees table.
Attempts:
2 left
💡 Hint
REVOKE removes specific privileges previously granted.
📝 Syntax
intermediate
2:00remaining
Identify the syntax error in this REVOKE statement
Which option contains a syntax error when trying to revoke privileges in MySQL?
AREVOKE INSERT, UPDATE ON sales FROM 'user2'@'%';
BREVOKE SELECT ON employees FROM 'user5'@'localhost';
CREVOKE DELETE ON database.table TO 'user4'@'localhost';
DREVOKE ALL PRIVILEGES ON *.* FROM 'user3'@'localhost';
Attempts:
2 left
💡 Hint
Check the keyword used to specify the user in REVOKE.
🧠 Conceptual
advanced
2:00remaining
What happens if you revoke a privilege not granted?
If you execute the command:

REVOKE UPDATE ON employees FROM 'user1'@'localhost';

but 'user1' never had the UPDATE privilege on employees, what will happen?
AMySQL will throw an error indicating the privilege was not granted.
BMySQL will silently succeed without error.
CMySQL will revoke all privileges from the user.
DMySQL will grant the UPDATE privilege instead.
Attempts:
2 left
💡 Hint
Think about how MySQL handles revoking privileges that do not exist.
query_result
advanced
2:00remaining
What privileges remain after this REVOKE?
Given a user 'user1'@'localhost' with privileges: SELECT, INSERT, UPDATE on database 'shop'.

After running:

REVOKE INSERT ON shop.* FROM 'user1'@'localhost';

Which privileges does 'user1' still have on 'shop'?
MySQL
REVOKE INSERT ON shop.* FROM 'user1'@'localhost';
ASELECT and UPDATE only
BINSERT only
CNo privileges remain
DSELECT, INSERT, and UPDATE remain
Attempts:
2 left
💡 Hint
REVOKE removes only the specified privilege.
🔧 Debug
expert
3:00remaining
Why does this REVOKE command fail?
A DBA runs this command:

REVOKE ALL PRIVILEGES ON *.* FROM 'user1'@'localhost';

But it returns an error:

ERROR 1410 (42000): You are not allowed to revoke all privileges from yourself

What is the reason for this error?
MySQL
REVOKE ALL PRIVILEGES ON *.* FROM 'user1'@'localhost';
AThe DBA is trying to revoke all privileges from the current user, which MySQL forbids.
BThe user 'user1'@'localhost' does not exist.
CThe syntax for revoking all privileges is incorrect; ON *.* is not allowed.
DMySQL does not support revoking ALL PRIVILEGES at once.
Attempts:
2 left
💡 Hint
Think about restrictions on revoking privileges from yourself.