So if you’ve ever created users and given them specific permissions from with SQL or the commandline, you will be familiar with a statement called FLUSH PRIVILEGES.

It is said that if you create a new user, or alter than user, you should run FLUSH PRIVILEGES in order for the MySQL Engine’s Session to take the change into immediate effect.

But what about if you GRANTed or REVOKEd a permission? Do you still need to use it?

It turns out that if you use GRANT or REVOKE, you do NOT need to FLUSH PRIVILEGES at all. Infact, internally MySQL keeps a copy of the Grants table in memory in order to not have to read it from disk each time a user makes a request to the database. When GRANT or REVOKE are called, the engine notices a change and goes and refreshes the in-memory table itself.

So the only time you need to use FLUSH PRIVILEGES is if you perform a INSERT, UPDATE or DELETE on the Grants table itself.

Categories: Content