<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="revoke">
      </a>
      15.7.1.8 REVOKE Statement
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045173161120">
  </a>
  <a class="indexterm" name="idm46045173160048">
  </a>
  <a class="indexterm" name="idm46045173159008">
  </a>
  <a class="indexterm" name="idm46045173157520">
  </a>
  <a class="indexterm" name="idm46045173156448">
  </a>
  <a class="indexterm" name="idm46045173154960">
  </a>
  <a class="indexterm" name="idm46045173153472">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7158117"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">REVOKE</span> <span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span>
    <em class="replaceable">priv_type</em> <span class="token punctuation">[</span><span class="token punctuation">(</span><em class="replaceable">column_list</em><span class="token punctuation">)</span><span class="token punctuation">]</span>
      <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">priv_type</em> <span class="token punctuation">[</span><span class="token punctuation">(</span><em class="replaceable">column_list</em><span class="token punctuation">)</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token keyword">ON</span> <span class="token punctuation">[</span><em class="replaceable">object_type</em><span class="token punctuation">]</span> <em class="replaceable">priv_level</em>
    <span class="token keyword">FROM</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">[</span><span class="token keyword">IGNORE</span> <span class="token keyword">UNKNOWN</span> <span class="token keyword">USER</span><span class="token punctuation">]</span>

<span class="token keyword">REVOKE</span> <span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span> <span class="token keyword">ALL</span> <span class="token punctuation">[</span><span class="token keyword">PRIVILEGES</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token keyword">GRANT</span> <span class="token keyword">OPTION</span>
    <span class="token keyword">FROM</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">[</span><span class="token keyword">IGNORE</span> <span class="token keyword">UNKNOWN</span> <span class="token keyword">USER</span><span class="token punctuation">]</span>

<span class="token keyword">REVOKE</span> <span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span> <span class="token keyword">PROXY</span> <span class="token keyword">ON</span> <em class="replaceable">user_or_role</em>
    <span class="token keyword">FROM</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">[</span><span class="token keyword">IGNORE</span> <span class="token keyword">UNKNOWN</span> <span class="token keyword">USER</span><span class="token punctuation">]</span>

<span class="token keyword">REVOKE</span> <span class="token punctuation">[</span><span class="token keyword">IF</span> <span class="token keyword">EXISTS</span><span class="token punctuation">]</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token keyword">FROM</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">[</span><span class="token keyword">IGNORE</span> <span class="token keyword">UNKNOWN</span> <span class="token keyword">USER</span><span class="token punctuation">]</span>

<em class="replaceable">user_or_role</em>: {
    <span class="token function"><em class="replaceable">user</em></span> <span class="token punctuation">(</span>see Section <span class="token number">8.2</span><span class="token punctuation">.</span><span class="token number">4</span><span class="token punctuation">,</span> “Specifying <span class="token keyword">Account</span> <span class="token keyword">Names</span>”<span class="token punctuation">)</span>
  <span class="token operator">|</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">(</span>see Section <span class="token number">8.2</span><span class="token punctuation">.</span><span class="token number">5</span><span class="token punctuation">,</span> “Specifying <span class="token keyword">Role</span> <span class="token keyword">Names</span>”
}</code></pre>
  </div>
  <p>
   The
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   statement enables
        system administrators to revoke privileges and roles, which can
        be revoked from user accounts and roles.
  </p>
  <p>
   For details on the levels at which privileges exist, the
        permissible
   <em class="replaceable">
    <code>
     priv_type
    </code>
   </em>
   ,
   <em class="replaceable">
    <code>
     priv_level
    </code>
   </em>
   , and
   <em class="replaceable">
    <code>
     object_type
    </code>
   </em>
   values, and the syntax
        for specifying users and passwords, see
   <a class="xref" href="grant.html" title="15.7.1.6 GRANT Statement">
    Section 15.7.1.6, “GRANT Statement”
   </a>
   .
  </p>
  <p>
   For information about roles, see
   <a class="xref" href="roles.html" title="8.2.10 Using Roles">
    Section 8.2.10, “Using Roles”
   </a>
   .
  </p>
  <p>
   When the
   <a class="link" href="server-system-variables.html#sysvar_read_only">
    <code class="literal">
     read_only
    </code>
   </a>
   system
        variable is enabled,
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   requires the
   <a class="link" href="privileges-provided.html#priv_connection-admin">
    <code class="literal">
     CONNECTION_ADMIN
    </code>
   </a>
   or
        privilege (or the deprecated
   <a class="link" href="privileges-provided.html#priv_super">
    <code class="literal">
     SUPER
    </code>
   </a>
   privilege), in addition to
        any other required privileges described in the following
        discussion.
  </p>
  <p>
   All the forms shown for
   <code class="literal">
    REVOKE
   </code>
   support an
   <code class="literal">
    IF EXISTS
   </code>
   option as well as an
   <code class="literal">
    IGNORE UNKNOWN USER
   </code>
   option. With neither of
        these modifications,
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   either succeeds for all named users and roles, or rolls back and
        has no effect if any error occurs; the statement is written to
        the binary log only if it succeeds for all named users and
        roles. The precise effects of
   <code class="literal">
    IF EXISTS
   </code>
   and
   <code class="literal">
    IGNORE UNKNOWN USER
   </code>
   are discussed later in
        this section.
  </p>
  <p>
   Each account name uses the format described in
   <a class="xref" href="account-names.html" title="8.2.4 Specifying Account Names">
    Section 8.2.4, “Specifying Account Names”
   </a>
   . Each role name uses the format
        described in
   <a class="xref" href="role-names.html" title="8.2.5 Specifying Role Names">
    Section 8.2.5, “Specifying Role Names”
   </a>
   . For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90556889"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">REVOKE</span> <span class="token keyword">INSERT</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token string">'jeffrey'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token keyword">REVOKE</span> <span class="token string">'role1'</span><span class="token punctuation">,</span> <span class="token string">'role2'</span> <span class="token keyword">FROM</span> <span class="token string">'user1'</span>@<span class="token string">'localhost'</span><span class="token punctuation">,</span> <span class="token string">'user2'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token keyword">REVOKE</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> world<span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token string">'role3'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   The host name part of the account or role name, if omitted,
        defaults to
   <code class="literal">
    '%'
   </code>
   .
  </p>
  <p>
   To use the first
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   syntax,
        you must have the
   <a class="link" href="privileges-provided.html#priv_grant-option">
    <code class="literal">
     GRANT OPTION
    </code>
   </a>
   privilege, and you must have the privileges that you are
        revoking.
  </p>
  <p>
   To revoke all privileges from a user, use one of the following
        statements; either of these statements drops all global,
        database, table, column, and routine privileges for the named
        users or roles:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95320333"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">REVOKE</span> <span class="token keyword">ALL</span> <span class="token keyword">PRIVILEGES</span><span class="token punctuation">,</span> <span class="token keyword">GRANT</span> <span class="token keyword">OPTION</span>
  <span class="token keyword">FROM</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

<span class="token keyword">REVOKE</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span>
  <span class="token keyword">FROM</span> <em class="replaceable">user_or_role</em> <span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">user_or_role</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
  </div>
  <p>
   Neither of the two statements just shown revokes any roles.
  </p>
  <p>
   To use these
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   statements,
        you must have the global
   <a class="link" href="privileges-provided.html#priv_create-user">
    <code class="literal">
     CREATE
        USER
    </code>
   </a>
   privilege, or the
   <a class="link" href="privileges-provided.html#priv_update">
    <code class="literal">
     UPDATE
    </code>
   </a>
   privilege for the
   <code class="literal">
    mysql
   </code>
   system schema.
  </p>
  <p>
   The syntax for which the
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   keyword is followed by one or more role names takes a
   <code class="literal">
    FROM
   </code>
   clause indicating one or more users or
        roles from which to revoke the roles.
  </p>
  <p>
   The
   <code class="literal">
    IF EXISTS
   </code>
   and
   <code class="literal">
    IGNORE UNKNOWN
        USER
   </code>
   options have the effects listed here:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       IF EXISTS
      </code>
      means that, if the target user
            or role exists but no such privilege or role is found
            assigned to the target for any reason, a warning is raised,
            instead of an error; if no privilege or role named by the
            statement is assigned to the target, the statement has no
            (other) effect. Otherwise,
      <code class="literal">
       REVOKE
      </code>
      executes normally; if the user does not exist, the statement
            raises an error.
     </p>
     <p>
      <span class="emphasis">
       <em>
        Example
       </em>
      </span>
      : Given table
      <code class="literal">
       t1
      </code>
      in database
      <code class="literal">
       test
      </code>
      ,
            we execute the following statements, with the results shown.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa14524165"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> jerry<span class="token variable">@localhost</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> test<span class="token punctuation">.</span>t1 <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1147 (42000)<span class="token punctuation">:</span> There is no such grant defined for user 'jerry' on host
'localhost' on table 't1' </span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> test<span class="token punctuation">.</span>t1 <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Warning
   Code<span class="token punctuation">:</span> 1147
Message<span class="token punctuation">:</span> There is no such grant defined for user 'jerry' on host 'localhost' on
table 't1' 
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      <code class="literal">
       IF EXISTS
      </code>
      causes an error to be demoted
            to a warning even if the privilege or role named does not
            exist, or the statement attempts to assign it at the wrong
            level.
     </p>
    </li>
    <li class="listitem">
     <p>
      If the
      <code class="literal">
       REVOKE
      </code>
      statement includes
      <code class="literal">
       IGNORE UNKNOWN USER
      </code>
      , the statement raises
            a warning for any target user or role named in the statement
            but not found; if no target named by the statement exists,
      <code class="literal">
       REVOKE
      </code>
      succeeds but has no actual effect.
            Otherwise, the statement executes as usual, and attempting
            to revoke a privilege not assigned to the target for
            whatever reason raises an error, as expected.
     </p>
     <p>
      <span class="emphasis">
       <em>
        Example
       </em>
      </span>
      (continuing from the previous
            example):
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa94668104"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">DROP</span> <span class="token keyword">USER</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> jerry<span class="token variable">@localhost</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> test<span class="token punctuation">.</span>t1 <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1147 (42000)<span class="token punctuation">:</span> There is no such grant defined for user 'jerry' on host
'localhost' on table 't1' </span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> test<span class="token punctuation">.</span>t1 <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span> <span class="token keyword">IGNORE</span> <span class="token keyword">UNKNOWN</span> <span class="token keyword">USER</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Warning
   Code<span class="token punctuation">:</span> 3162
Message<span class="token punctuation">:</span> Authorization ID jerry does not exist.
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      The combination of
      <code class="literal">
       IF EXISTS
      </code>
      and
      <code class="literal">
       IGNORE UNKNOWN USER
      </code>
      means that
      <code class="literal">
       REVOKE
      </code>
      never raises an error for an
            unknown target user or role or for an unassigned or
            unavailable privilege, and the statement as whole in such
            cases succeeds; roles or privileges are removed from
            existing target users or roles whenever possible, and any
            revocation which is not possible raises a warning and
            executes as a
      <code class="literal">
       NOOP
      </code>
      .
     </p>
     <p>
      <span class="emphasis">
       <em>
        Example
       </em>
      </span>
      (again continuing from example
            in the previous item):
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa35459549"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true"># No such user, no such role</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">DROP</span> <span class="token keyword">ROLE</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> Bogus<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.02 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Level <span class="token punctuation">|</span> Code <span class="token punctuation">|</span> Message                                      <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Note  <span class="token punctuation">|</span> 3162 <span class="token punctuation">|</span> Authorization ID 'Bogus'@'%' does not exist. <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>

<span class="token comment" spellcheck="true"># This statement attempts to revoke a nonexistent role from a nonexistent user</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> Bogus <span class="token keyword">ON</span> test <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3619 (HY000)<span class="token punctuation">:</span> Illegal privilege level specified for test

# The same, with IF EXISTS</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> Bogus <span class="token keyword">ON</span> test <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1147 (42000)<span class="token punctuation">:</span> There is no such grant defined for user 'jerry' on host
'localhost' on table 'test' 

# The same, with IGNORE UNKNOWN USER</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> Bogus <span class="token keyword">ON</span> test <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span> <span class="token keyword">IGNORE</span> <span class="token keyword">UNKNOWN</span> <span class="token keyword">USER</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3619 (HY000)<span class="token punctuation">:</span> Illegal privilege level specified for test

# The same, with both options</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">REVOKE</span> <span class="token keyword">IF</span> <span class="token keyword">EXISTS</span> Bogus <span class="token keyword">ON</span> test <span class="token keyword">FROM</span> jerry<span class="token variable">@localhost</span> <span class="token keyword">IGNORE</span> <span class="token keyword">UNKNOWN</span> <span class="token keyword">USER</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 2 warnings (0.01 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Level   <span class="token punctuation">|</span> Code <span class="token punctuation">|</span> Message                                    <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Warning <span class="token punctuation">|</span> 3619 <span class="token punctuation">|</span> Illegal privilege level specified for test <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> Warning <span class="token punctuation">|</span> 3162 <span class="token punctuation">|</span> Authorization ID jerry does not exist.     <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">2 rows in set (0.00 sec)</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
  <p>
   Roles named in the
   <a class="link" href="server-system-variables.html#sysvar_mandatory_roles">
    <code class="literal">
     mandatory_roles
    </code>
   </a>
   system variable
        value cannot be revoked. When
   <code class="literal">
    IF EXISTS
   </code>
   and
   <code class="literal">
    IGNORE UNKNOWN USER
   </code>
   are used together in a
        statement that tries to remove a mandatory privilege, the error
        normally raised by attempting to do this is demoted to a
        warning; the statement executes successfully, but does not make
        any changes.
  </p>
  <p>
   A revoked role immediately affects any user account from which
        it was revoked, such that within any current session for the
        account, its privileges are adjusted for the next statement
        executed.
  </p>
  <p>
   Revoking a role revokes the role itself, not the privileges that
        it represents. Suppose that an account is granted a role that
        includes a given privilege, and is also granted the privilege
        explicitly or another role that includes the privilege. In this
        case, the account still possesses that privilege if the first
        role is revoked. For example, if an account is granted two roles
        that each include
   <a class="link" href="privileges-provided.html#priv_select">
    <code class="literal">
     SELECT
    </code>
   </a>
   , the
        account still can select after either role is revoked.
  </p>
  <p>
   <code class="literal">
    REVOKE ALL ON *.*
   </code>
   (at the global level)
        revokes all granted static global privileges and all granted
        dynamic privileges.
  </p>
  <p>
   A revoked privilege that is granted but not known to the server
        is revoked with a warning. This situation can occur for dynamic
        privileges. For example, a dynamic privilege can be granted
        while the component that registers it is installed, but if that
        component is subsequently uninstalled, the privilege becomes
        unregistered, although accounts that possess the privilege still
        possess it and it can be revoked from them.
  </p>
  <p>
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   removes privileges, but
        does not remove rows from the
   <code class="literal">
    mysql.user
   </code>
   system table. To remove a user account entirely, use
   <a class="link" href="drop-user.html" title="15.7.1.5 DROP USER Statement">
    <code class="literal">
     DROP USER
    </code>
   </a>
   . See
   <a class="xref" href="drop-user.html" title="15.7.1.5 DROP USER Statement">
    Section 15.7.1.5, “DROP USER Statement”
   </a>
   .
  </p>
  <p>
   If the grant tables hold privilege rows that contain mixed-case
        database or table names and the
   <a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
    <code class="literal">
     lower_case_table_names
    </code>
   </a>
   system
        variable is set to a nonzero value,
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   cannot be used to revoke
        these privileges. It is necessary in such cases to manipulate
        the grant tables directly. (
   <a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
    <code class="literal">
     GRANT
    </code>
   </a>
   does not create such rows when
   <a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
    <code class="literal">
     lower_case_table_names
    </code>
   </a>
   is set,
        but such rows might have been created prior to setting the
        variable. The
   <a class="link" href="server-system-variables.html#sysvar_lower_case_table_names">
    <code class="literal">
     lower_case_table_names
    </code>
   </a>
   setting
        can only be configured when initializing the server.)
  </p>
  <p>
   When successfully executed from the
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   program,
   <a class="link" href="revoke.html" title="15.7.1.8 REVOKE Statement">
    <code class="literal">
     REVOKE
    </code>
   </a>
   responds with
   <code class="literal">
    Query OK, 0 rows affected
   </code>
   . To determine what
        privileges remain after the operation, use
   <a class="link" href="show-grants.html" title="15.7.7.22 SHOW GRANTS Statement">
    <code class="literal">
     SHOW GRANTS
    </code>
   </a>
   . See
   <a class="xref" href="show-grants.html" title="15.7.7.22 SHOW GRANTS Statement">
    Section 15.7.7.22, “SHOW GRANTS Statement”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
