简体   繁体   English

MySQL查询日志

[英]MySQL Query log

Is there a way I can find out how many select, update, insert and rest of the queries have been executed by MySQL server ? 有没有办法可以找出MySQL服务器执行了多少次选择,更新,插入和其他查询? Can it be in last 1 day or week ? 可以在最后1天或一周吗?

Yes, there is a way! 是的,有办法! You can set the server to write logs about client connects/disconnects and every statement which was executed to a log file. 您可以将服务器设置为写入有关客户端连接/断开连接的日志以及已执行到日志文件的每个语句。 Have a look here . 看看这里

Start General Query Log, it allows storing log info into table. 启动常规查询日志,它允许将日志信息存储到表中。

Then write a SELECT query to read data from mysql . 然后编写一个SELECT查询来从mysql读取数据。 general_log table, add WHERE condition to filter result by date. general_log表,添加WHERE条件以按日期过滤结果。 Then analyze (parse) data from the argument field, it contains executed queries. 然后从argument字段分析(解析)数据,它包含已执行的查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM