How do I enable the MySQL function that logs each SQL query statement received from clients and the time that query statement has submitted? Can I do that in phpmyadmin or NaviCat? How do I analyse the log?
相关问题
- 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
You can disable or enable the general query log (which logs all queries) with
On Windows you can simply go to
Insert this line in my.ini
The my.ini file finally looks like this
There is bug in MySQL 5.6 version. Even mysqld show as :
Realy settings are reading in following order :
Check file: "C:\ProgramData\MySQL\MySQL Server 5.6\my.ini"
Hope it help somebody.
I use this method for logging when I want to quickly optimize different page loads. It's a little tip...
Logging to a TABLE
You can then select from my
mysql.general_log
table to retrieve recent queries.I can then do something similar to
tail -f
on the mysql.log, but with more refinements...This makes it easy to see my queries that I can try and cut back. I use 8 seconds interval to only fetch queries executed within the last 8 seconds.
First, Remember that this logfile can grow very large on a busy server.
For mysql < 5.1.29:
To enable the query log, put this in
/etc/my.cnf
in the[mysqld]
sectionAlso, to enable it from MySQL console
See http://dev.mysql.com/doc/refman/5.1/en/query-log.html
For mysql 5.1.29+
With mysql 5.1.29+ , the
log
option is deprecated. To specify the logfile and enable logging, use this in my.cnf in the[mysqld]
section:Alternately, to turn on logging from MySQL console (must also specify log file location somehow, or find the default location):
Also note that there are additional options to log only slow queries, or those which do not use indexes.
In phpMyAdmin 4.0, you go to Status > Monitor. In there you can enable the slow query log and general log, see a live monitor, select a portion of the graph, see the related queries and analyse them.