Clear MySQL query cache without restarting server

MysqlCaching

Mysql Problem Overview


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

Mysql Solutions


Solution 1 - Mysql

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.

Solution 2 - Mysql

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;

Solution 3 - Mysql

according the documentation, this should do it...

RESET QUERY CACHE 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMahoor13View Question on Stackoverflow
Solution 1 - MysqlJohn ParkerView Answer on Stackoverflow
Solution 2 - MysqlLeszekView Answer on Stackoverflow
Solution 3 - MysqlManu EidenbergerView Answer on Stackoverflow