I would like to know if there is a way to revoke certain privileges to a mysql user while in session. For example the user 'anonymous' is connected to my server and as root I revoke the INSERT privilege
I know the command to revoke is this...
REVOKE INSERT ON *.* FROM 'anonimo'@'%';
But I want that privilege to be removed while logged in because I have already applied that command and updated privileges with the
FLUSH PRIVILEGES;
And even so, it continues to insert data, until I log in again with the user, it already revokes the privilege, but I would like to know if there is a way to revoke it as soon as the user is in session.
According to the mysql tutorial :
My free translation would be:
When do the MySQL REVOKE commands take effect?
The application of the REVOKE statement depends on the privilege level of the permission being revoked, according to:
Changes made to global privileges take effect only when the client connects to MySQL in subsequent sessions. The changes do not apply to currently logged in users.
Changes to database-level privileges are applied after the next use of the clause
use
.Changes to table and column level privileges are applied to all queries that are submitted after the privilege change is made.
So if you want the changes to take effect immediately, I suggest changing your strategy and giving specific privileges.
It would allow you to revoke said privilege and have it applied from the next query launched by the user, even if it is connected:
I've been doing some research and I think that's the best way to do it to revoke INSERT permissions , however there are TRIGGERS that are triggers that are executed after an action, so I would think that for this example it can be used.
This is the MySQL documentation , you can do some research and see if it works for you.