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
This was already in a comment, but deserves its own answer: Without editing the config files: in mysql, as root, do
Don't forget to turn it off afterwards.
I also wanted to enable the MySQL log file to see the queries and I have resolved this with the below instructions
/etc/mysql/mysql.conf.d
and enable the below lines
/etc/init.d/mysql restart
/var/log/mysql/
and check the logsNot exactly an answer to the question because the question already has great answers. This is a side info. Enabling general_log really put a dent on MySQL performance. I left
general_log =1
accidentally on a production server and spent hours finding out why performance was not comparable to a similar setup on other servers. Then I found this which explains the impact of enabling general log. http://www.fromdual.com/general_query_log_vs_mysql_performance.Gist of the story, don't put
general_log=1
in the.cnf
file. Instead useset global general_log =1
for a brief duration just to log enough to find out what you are trying to find out and then turn it off.To enable the query log in MAC Machine:
Open the following file:
Set the query log url under 'mysqld' section as follows:
Few machine’s are not logging query properly, So that case you can enable it from MySQL console
I had to drop and recreate the general log at one point. During the recreation, character sets got messed up and I ended up having this error in the logs:
[ERROR] Incorrect definition of table mysql.general_log: expected the type of column 'user_host' at position 1 to have character set 'utf8' but found character set 'latin1'
So if the standard answer of "check to make sure logging is on" doesn't work for you, check to make sure your fields have the right character set.
for mysql>=5.5 only for slow queries (1 second and more) my.cfg