Flush privileges
Many tutorials and instructions to set up applications tell the users to issue FLUSH PRIVILEGES
. So, what is this? And when do we need to use it?
The CREATE USER
, ALTER USER
, and GRANT
permissions, along with many other user and permission statements, indirectly modify the system tables that are stored in the mysql
schema. At startup, these tables are loaded into memory and, after every statement that modifies the users and/or permissions, these are again loaded into memory.
However, if you directly modify the tables in the mysql
schema with INSERT
, UPDATE
, and DELETE
statements, you need to force MySQL to refresh the copies of these tables it has in memory. This is where the FLUSH PRIVILEGES
statement comes in. It precisely does that. Note that we do not recommend you modify these tables directly. So, as long as you stick to the supported commands to modify users, you never need to use this command.