I have a MySQL user with database-level privileges.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON mydb.* TO 'theuser';
The user can create tables and insert rows into them.
When the user exceeds the limits, for example, the number of allowed rows in his plan, I want to revoke the INSERT
privilege. So the user cannot insert new rows into the tables anymore. It's a plan with soft limits.
I know I can execute the following query:
REVOKE INSERT ON mydb.* FROM 'theuser';
But it doesn't affect until the next use mydb
.
According to MySQL docs:
A grant table reload affects privileges for each existing client connection as follows:
- Table and column privilege changes take effect with the client's next request.
- Database privilege changes take effect the next time the client executes a USE db_name statement.
- Global privileges and passwords are unaffected for a connected client. These changes take effect only for subsequent connections.
So my problem is how can I force MySQL to reload database-level privileges without the need for "use db_name" statement, just like table-level privileges.