I need to update a user’s permissions in MySQL without leaving the user temporarily without any privileges. I’ve identified two possible approaches:
-
Using a transaction:
START TRANSACTION; REVOKE INSERT, UPDATE ON mydatabase.* FROM 'user1'@'localhost'; GRANT SELECT, INSERT ON mydatabase.* TO 'user1'@'localhost'; COMMIT;
-
Directly updating the mysql system tables, although the MySQL documentation advises against this: MySQL Documentation on Privilege Changes.
My questions are:
-
Could my first method (wrapping the REVOKE and GRANT statements in a transaction) result in a very short period where the user is left without any privileges between the REVOKE and GRANT?
-
Why is directly updating the MySQL system tables not recommended?
-
Which approach is better for ensuring the user never ends up without the necessary permissions, even momentarily?