2

I am using Mysql community edition. I want to know how can I find last few queries fired on current instance of mysql? Is there any command or query that lists out what were last 20 queries and their memory consumption? If there is no command, whether queries are logged anywhere?

Another thing I want to know is there any command that shows currently fired queries? Something like top command on Linux systems.

I-M-JM
  • 15,732
  • 26
  • 77
  • 103
  • See this related question: http://stackoverflow.com/questions/650238/how-to-show-the-last-queries-executed-on-mysql – User May 19 '14 at 06:39

3 Answers3

3

If you use MySQL 5.6 or later, you can use the PERFORMANCE_SCHEMA to track recent queries, and also get quite a bit of information about them.

https://dev.mysql.com/doc/refman/5.6/en/performance-schema-statement-tables.html

However, it's kind of complex to setup and use the PERFORMANCE_SCHEMA. You might like to look at one of the toolkits that are under development, which try to make it easier:

  • mysql-sys, probably most likely to become standard
  • dbahelper, experimental code by the same person who developed mysql-sys
  • ps_tools
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
1

Yes you can find in mysql query log. if it is enabled.

Note: check your my.cnf configuration file if it is enabled.

Go through this question How to show the last queries executed on MySQL? will help you.

Community
  • 1
  • 1
1

You will need to enable the general query log for queries which have completed execution. To see what's happening right now, like 'top', check out mytop, or for a less sophisticated view, try mysqladmin processlist, or execute the query SHOW PROCESSLIST;

Paul Dixon
  • 295,876
  • 54
  • 310
  • 348