Complete Privilege Revocation for George
Revoke All Privileges from a User
Write a MySQL query to revoke all privileges from the user "george".
Solution:
-- This command removes all privileges previously granted to the user 'george'
-- Also removes any GRANT OPTION if it exists, for localhost connections
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'george'@'localhost';
Explanation:
- Purpose of the Query:
- The goal is to remove every privilege and the ability to grant privileges from the user "george".
- This demonstrates the complete revocation of access rights using the REVOKE statement.
- Key Components:
- REVOKE ALL PRIVILEGES, GRANT OPTION : Specifies the removal of all assigned privileges.
- FROM 'george'@'localhost' : Identifies the user whose privileges are being revoked.
- Real-World Application:
- Useful when a user no longer requires access to any part of the database, or before deleting a user.
Notes:
- Verify current privileges before revocation to ensure accuracy.
- This operation immediately affects the user's ability to access the database.
For more Practice: Solve these Related Problems:
- Write a MySQL query to revoke all privileges and the GRANT OPTION from the user "george"@'localhost'.
- Write a MySQL query to completely remove all privileges from "george" and then verify the revocation using SHOW GRANTS.
- Write a MySQL query to revoke all privileges from "george" and then check the mysql.user table for any residual permissions.
- Write a MySQL query to revoke every privilege from "george" and simulate an attempted operation to confirm the revocation.
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous MySQL Exercise: Create a User with Limited Privileges on a Specific Table.
Next MySQL Exercise: Show All Users from the MySQL System Database.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics