Does MySQL have an admin-only mode?
-
07-06-2021 - |
Question
We need to migrate and archive some records in MySQL. We don't want to take down our entire site (most reads are serviced from a separate cache in the app layer anyway), but we need to prevent anyone from attempting to register or do anything that changes the database.
Does MySQL have a feature that puts the database into an admin
-like mode where only the administrator can manipulate records while connections from the application layer (using a separate db account) are rejected?
Solution
You can use the read_only
system variable. Only users with super privileges will be able to change anything.
Ref: http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_read_only
OTHER TIPS
You can do several things, but I don't think they are a good solution: there's a good change your applications won't react very happy to this :)
That said, you can just remove the appropriate rights from your db-user, that'll do it. They'll essentially be in read-only mode.
Check out http://dev.mysql.com/doc/refman/5.1/en/revoke.html on how to revoke, and http://dev.mysql.com/doc/refman/5.1/en/grant.html on how to re-grant certain stuff :)