在mysql中记录所有查询(Log all queries in mysql)

编程入门 行业动态 更新时间:2024-10-26 16:22:16
mysql中记录所有查询(Log all queries in mysql)

是否可以在我的mysql数据库上启用审核日志记录?

我基本上是要监视一个小时的所有查询,并将日志转储到一个文件。

Is it possible for me to turn on audit logging on my mysql database?

I basically want to monitor all queries for an hour, and dump the log to a file.

最满意答案

使用--log选项启动mysql:

mysqld --log=log_file_name

或将以下内容放在my.cnf文件中:

log = log_file_name

任何一个都会将所有查询记录到log_file_name。

您也可以使用--log-slow-queries选项而不是--log来仅记录缓慢查询。 默认情况下,需要10秒或更长时间的查询被认为很慢,您可以通过将long_query_time为在记录之前执行的查询所需的秒数来进行更改。

Start mysql with the --log option:

mysqld --log=log_file_name

or place the following in your my.cnf file:

log = log_file_name

Either one will log all queries to log_file_name.

You can also log only slow queries using the --log-slow-queries option instead of --log. By default, queries that take 10 seconds or longer are considered slow, you can change this by setting long_query_time to the number of seconds a query must take to execute before being logged.

更多推荐

本文发布于:2023-08-07 07:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1462018.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:mysql   Log   queries

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!