无需重启服务器即可清除 MySQL 查询缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5231678/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 19:01:22  来源:igfitidea点击:

Clear MySQL query cache without restarting server

mysqlcaching

提问by Mahoor13

Is there any way to clearmysql query cachewithout restarting mySQL server?

有没有办法在不重新启动 mySQL 服务器的情况下清除mysql查询缓存

回答by John Parker

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 Maintenancesection of the MySQL manual for more information.

有关更多信息,请参阅MySQL 手册的查询缓存状态和维护部分。

回答by Leszek

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

在我的系统(Ubuntu 12.04)中,我发现RESET QUERY CACHE甚至重新启动 mysql 服务器还不够。这是由于内存盘缓存造成的
每次查询后,我都会清理终端中的磁盘缓存:

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

and then reset the query cache in mysql client:

然后在 mysql 客户端重置查询缓存:

RESET QUERY CACHE;

回答by Manu Eidenberger

according the documentation, this should do it...

根据文档,这应该这样做......

RESET QUERY CACHE