Q:

Dynamically assign and revoke MySQL user privileges

So I am following a course on Lynda.com about IT Security. They were talking on the Least Privileges Principle, how users or processes should have the minimum amount of privileges for the minimum amount of time and it got me thinking, would it be of any use to dynamically assign and revoke privileges to a MySQL user.
So as an example, lets say that on a Saas website, there are two MySQL users. One is 'admin'@'localhost' and the other is 'worker'@'xxx'. The Worker user will hold no privileges until it signals the admin that it needs to write to the database. After the worker user is done, it signals again to the admin user that its job is finished and the admin user revokes the writing privilege. Making the worker user useless in the case it got compromised. 

A:

This is generally a very good practice and often employed by large enterprises.
For example, have a look at the security applied to operational staff working on Microsoft Office 365 & Azure. They have NO access to data at all. When they need to trouble-shoot something and need access, they have to follow a process whereby they request the access from their ops security team along with the reasons and timescale. They are given access for a very limited time.
Of course, you need to balance this approach with the overheads of managing it. To be successful in any organisation, you would need to be able to automate the request/access process. That brings its own risks which you would offset using monitored audit logs.

