To revoke privileges, you use the REVOKE command. It works very similarly to the GRANT command, but you use FROM instead of TO.
Here are the most common ways to do it:
1. Revoke Specific Privileges
If you want to take away just the INSERT permission from hr_user but let them keep SELECT access:
REVOKE INSERT ON company_db.employees FROM 'hr_user'@'localhost';
2. Revoke All Privileges
If you want to strip a user of all permissions on a specific database or table:
REVOKE ALL PRIVILEGES ON company_db.employees FROM 'intern'@'localhost';
3. Verify the Change
After revoking, it is a best practice to check the user's current permissions to ensure they were removed:
SHOW GRANTS FOR 'hr_user'@'localhost';
Note: Revoking a privilege does not delete the user account. The user can still log in, but they will receive an "Access denied" error if they try to perform an action they no longer have permission for.
Would you like to try revoking the INSERT privilege from your hr_user now to see it in action?