← Back to MySQL Course | Chapter 18: User Management & Security | Lesson 3 of 6

REVOKE Privileges

REVOKE पहले दी गई एक permission slip वापस लेने जैसा है, ताकि वह person अब वह चीज़ न कर सके।
Syntax
sql
REVOKE privilege1, privilege2
ON database_name.table_name
FROM 'username'@'host';

REVOKE क्या है?

REVOKE GRANT का direct opposite है — एक permission बाँटने के बजाय, यह पहले assign की गई किसी को हटा देता है, जो तब ज़रूरी है जब किसी user का role बदल जाए या जिस project तक उसे access थी वह खत्म हो जाए।

उदाहरण: What is REVOKE?

sql
REVOKE INSERT ON mydb.* FROM 'app_user'@'localhost';

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

All Privileges Revoke करना

किसी account से एक साथ हर privilege revoke करना login को खुद intact छोड़ते हुए इसे database पर act करने की किसी भी ability से strip कर देता है, effectively account को पूरी तरह delete किए बिना neutralize करते हुए।

उदाहरण: Revoking All Privileges

sql
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'app_user'@'localhost';

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

Specific Column Privileges Revoke करना

जैसे column-level privileges grant की जा सकती हैं, उन्हें individually revoke भी किया जा सकता है, table के बाकी हर column पर user की permissions unchanged रखते हुए सिर्फ एक specific column का access हटाना।

उदाहरण: Revoking Specific Column Privileges

sql
REVOKE SELECT (salary) ON mydb.employees FROM 'app_user'@'localhost';

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

Revocations Apply करना

permissions revoke करने के बाद, एक flush command चलाना ensure करता है कि change तुरंत effect में आए बजाय cached privilege data के खुद refresh होने का wait करने के।

उदाहरण: Applying Revocations

sql
REVOKE INSERT ON mydb.* FROM 'app_user'@'localhost';
FLUSH PRIVILEGES;

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

REVOKE के साथ Common Mistakes

एक REVOKE statement को original GRANT के exact scope से match करना ज़रूरी है — आप एक broader global wildcard इस्तेमाल करके एक database-level permission नहीं हटा सकते, इसलिए syntax को यह mirror करना ज़रूरी है कि access originally कैसे grant किया गया था।

उदाहरण: Common Mistakes with REVOKE

sql
-- Granted at the database level:
GRANT SELECT ON mydb.* TO 'app_user'@'localhost';
-- Wrong: a broader global scope doesn't match the original grant
-- REVOKE SELECT ON *.* FROM 'app_user'@'localhost';
-- Correct: mirror the original scope exactly
REVOKE SELECT ON mydb.* FROM 'app_user'@'localhost';

⚠️ This is MySQL-specific syntax. It cannot run in the browser editor. Practice this on your local MySQL installation.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. जिस host account को grant किया गया था उससे अलग host account से revoke करना, जैसे app_user@localhost के बजाय app_user@'%'।
  2. यह उम्मीद करना कि REVOKE account delete कर देगा, जबकि user अभी भी log in कर सकता है।
  3. एक अलग level पर granted privilege revoke करना, जैसे mydb.* जब यह *.* पर grant की गई थी।
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.