Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5951263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:30:43+00:00 2026-05-22T17:30:43+00:00

Is it possible to create triggers that will grant or revoke permissions to users

  • 0

Is it possible to create triggers that will grant or revoke permissions to users in mysql 5.1?

I tried this one :

delimiter //

create trigger sup_tog
before update on members
for each row begin
if old.fname = "xyz" and new.status = "b"
then
revoke select, update on mkdb.* from xyz;
end if;

end//

The error message that I got is:

Error Code: 1422. Explicit or implicit
commit is not allowed in stored
function or trigger.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:30:43+00:00Added an answer on May 22, 2026 at 5:30 pm

    You can manipulate the rights tables in the mysql database directly.

    table mysql.user holds universal rights for users (access rights to all databases)
    table mysql.db holds access rights per database
    table mysql.table_priv: access rights per table

    Change your trigger into:

    DELIMITER $$
    
    CREATE TRIGGER bu_members BEFORE UPDATE ON members FOR EACH ROW
    BEGIN
      IF old.fname = "xyz" AND new.status = "b" THEN BEGIN
        /*revoke select, update on mkdb.* from xyz;*/
        UPDATE mysql.db SET 
          select_priv = 'N'
          , update_priv = 'N' 
        WHERE mysql.db.user = 'xyz' AND mysql.db.db = 'mkdb';
      END; END IF;
    
    END $$
    

    Note that the changes will only take effect after the current transaction ends.
    This must happen outside the trigger as @Denis has already explained.

    enter image description here Warning
    Beware that the structure of the mysql schema can change (and has changed in the past).
    If this happens your query may break.
    GRANT/REVOKE do not have this problem.
    Use this sort of code with caution and check to see if everything still works if you upgrade your MySQL server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create a trigger that will not be in a transaction?
Possible Duplicate: Reset JavaScript Counter? I'm trying to create a function that will trigger
Is it possible to create a Trigger that is triggered based on a ScrollViewer
I am trying to create some MySQL code that will invoke a Java program
Is it possible to create a trigger on a field within a table being
Is it possible to create federated Subversion servers? As in one server at location
This is a followup to: MySQL - Is it possible to get all sub-items
Possible Duplicate: How do I create unique constraint that also allows nulls in sql
I need to create a view or a table valued function that returns one
Is it possible to create an event listener in jQuery that can be bound

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.