如何显示在MySQL上执行的最后一个查询? [英] How to show the last queries executed on MySQL?
本文介绍了如何显示在MySQL上执行的最后一个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何查询/方式来显示在 ALL 个服务器上执行的最后一个查询?
Is there any query/way to show the last queries executed on ALL servers?
推荐答案
对于那些使用MySQL> = 5.1.12的人来说,可以在运行时全局控制此选项:
For those blessed with MySQL >= 5.1.12, you can control this option globally at runtime:
- 执行
SET GLOBAL log_output = 'TABLE';
- 执行
SET GLOBAL general_log = 'ON';
- 看看表
mysql.general_log
- Execute
SET GLOBAL log_output = 'TABLE';
- Execute
SET GLOBAL general_log = 'ON';
- Take a look at the table
mysql.general_log
如果您希望输出到文件而不是表:
If you prefer to output to a file instead of a table:
-
SET GLOBAL log_output = "FILE";
默认. -
SET GLOBAL general_log_file = "/path/to/your/logfile.log";
-
SET GLOBAL general_log = 'ON';
SET GLOBAL log_output = "FILE";
the default.SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';
我更喜欢这种方法来编辑.cnf文件,因为:
I prefer this method to editing .cnf files because:
- 您不编辑
my.cnf
文件,并可能永久打开日志记录 - 您不会在文件系统中四处寻找查询日志-甚至更糟的是,由于需要完美的目的地而分心.
/var/log /var/data/log
/opt /home/mysql_savior/var
- 您不必重新启动服务器并中断与服务器的任何当前连接.
- 重新启动服务器会将您留在开始的位置(默认情况下,日志仍处于关闭状态)
- you're not editing the
my.cnf
file and potentially permanently turning on logging - you're not fishing around the filesystem looking for the query log - or even worse, distracted by the need for the perfect destination.
/var/log /var/data/log
/opt /home/mysql_savior/var
- You don't have to restart the server and interrupt any current connections to it.
- restarting the server leaves you where you started (log is by default still off)
有关更多信息,请参见 MySQL 5.1参考手册-服务器系统变量-general_log
For more information, see MySQL 5.1 Reference Manual - Server System Variables - general_log
这篇关于如何显示在MySQL上执行的最后一个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文