在mysql中记录所有查询 [英] Log all queries in mysql

查看:348
本文介绍了在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:

Start mysql with the --log option:

mysqld --log=log_file_name

或在您的my.cnf文件中放置以下内容:

or place the following in your my.cnf file:

log = log_file_name

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

Either one will log all queries to log_file_name.

您也可以使用--log-slow-queries选项而不是--log来仅记录慢速查询.默认情况下,耗时10秒或更长时间的查询被认为是缓慢的,您可以通过将long_query_time设置为查询在记录之前必须执行的秒数来更改它.

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.

这篇关于在mysql中记录所有查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆