Is there any query/way to show the last queries executed on ALL servers?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- I want to trace logs using a Macro multi parameter
- Why sometimes there is one of more gap(s) in the v
If you don't feel like changing your MySQL configuration you could use an SQL profiler like "Neor Profile SQL" http://www.profilesql.com .
After reading Paul's answer, I went on digging for more information on https://dev.mysql.com/doc/refman/5.7/en/query-log.html
I found a really useful code by a person. Here's the summary of the context.
(Note: The following code is not mine)
This script is an example to keep the table clean which will help you to reduce your table size. As after a day, there will be about 180k queries of log. ( in a file, it would be 30MB per day)
You need to add an additional column (event_unix) and then you can use this script to keep the log clean... it will update the timestamp into a Unix-timestamp, delete the logs older than 1 day and then update the event_time into Timestamp from event_unix... sounds a bit confusing, but it's working great.
Commands for the new column:
Cleanup script:
Credit goes to Sebastian Kaiser (Original writer of the code).
Hope someone will find it useful as I did.
Maybe you could find that out by looking at the query log.
You can do the flowing thing for monitoring mysql query logs.
Open mysql configuration file my.cnf
Search following lines under a
[mysqld]
heading and uncomment these lines to enable logRestart your mysql server for reflect changes
Monitor mysql server log with following command in terminal
If mysql binlog is enabled you can check the commands ran by user by executing following command in linux console by browsing to mysql binlog directory
enabling
or general log will have an effect on performance of mysql
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
If you prefer to output to a file instead of a table:
SET GLOBAL log_output = "FILE";
the default.SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';
I prefer this method to editing .cnf files because:
my.cnf
file and potentially permanently turning on logging/var/log /var/data/log
/opt /home/mysql_savior/var
For more information, see MySQL 5.1 Reference Manual - Server System Variables - general_log