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.
You can manipulate the rights tables in the
mysqldatabase directly.table
mysql.userholds universal rights for users (access rights to all databases)table
mysql.dbholds access rights per databasetable
mysql.table_priv: access rights per tableChange your trigger into:
Note that the changes will only take effect after the current transaction ends.
This must happen outside the trigger as @Denis has already explained.
Beware that the structure of the
mysqlschema can change (and has changed in the past).If this happens your query may break.
GRANT/REVOKEdo 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.