Reputation: 1482
Does mysql server keeps records of queries executed on it, if it does so , is it possible to retrieve those queries.
Thanks.
Upvotes: 1
Views: 1279
Reputation: 115530
If you want to keep record of all queries that are executed, you can enable either the General Query Log or the Slow Query Log and set the threshold to 0 seconds (any query that takes more than 0 seconds will be logged).
Another option is the Binary log. However, binary log does not keep record of queries like SELECT
or SHOW
that do not modify data.
Note that these logs get pretty big pretty fast in a server with traffic. And that both might contain passwords so they have to be protected from unauthorized eyes.
Upvotes: 2
Reputation: 13600
There's another option - use a profiler.
For instance: http://www.jetprofiler.com/
Upvotes: 0
Reputation: 14638
You can use MySQL Proxy which stands between client app and RDBMS itself.
http://forge.mysql.com/wiki/MySQL_Proxy
You can see online queries and also it allows you to rewrite queries based on rules.
Upvotes: 1
Reputation: 53830
You can use the General Query Log, which logs all queries in plain text.
We have this enabled on our development environment only. It shouldn't be a problem to turn this on temporarily on a production server during off-peak times.
If you're looking for slow queries, you may as well use the Slow Query Log.
Upvotes: 2