Clear MySQL query cache without restarting server

2020-01-26 13:41发布

问题:

Is there any way to clear mysql query cache without restarting mySQL server?

回答1:

I believe you can use...

RESET QUERY CACHE;

...if the user you're running as has reload rights. Alternatively, you can defragment the query cache via...

FLUSH QUERY CACHE;

See the Query Cache Status and Maintenance section of the MySQL manual for more information.



回答2:

In my system (Ubuntu 12.04) I found RESET QUERY CACHE and even restarting mysql server not enough. This was due to memory disc caching.
After each query, I clean the disc cache in the terminal:

sync && echo 3 | sudo tee /proc/sys/vm/drop_caches

and then reset the query cache in mysql client:

RESET QUERY CACHE;


回答3:

according the documentation, this should do it...

RESET QUERY CACHE 


标签: mysql caching