Clear MySQL query cache without restarting server

2020-01-26 13:16发布

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

标签: mysql caching
3条回答
乱世女痞
2楼-- · 2020-01-26 13:31

according the documentation, this should do it...

RESET QUERY CACHE 
查看更多
混吃等死
3楼-- · 2020-01-26 13:32

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;
查看更多
淡お忘
4楼-- · 2020-01-26 13:48

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.

查看更多
登录 后发表回答