The function of the query log is to record all the SQL statements sent by the client, that is, to record all operations of the client
Log parameter is going to be obsolete, now replace with General_log
Open Query Log Feature
Mysql> showvariables like "%log";
+----------------+-------+
| variable_name| Value |
+----------------+-------+
| Back_log| 30:
| General_log| Off|
| Log| Off|
| relay_log| |
| Slow_query_log | Off|
| Sync_binlog| 0|
+----------------+-------+
6 rows in Set (0.01 sec)
mysql> set global general_log=1;
Query OK, 0 rows affected (0.18 sec)
Mysql> set globallog=1;
Query OK, 0 rows affected, 1 warning (0.00sec)
Mysql> showvariables like "%log";
+----------------+-------+
| variable_name| Value |
+----------------+-------+
| Back_log| 30:
| General_log| on|
| Log| on|
| relay_log| |
| Slow_query_log | Off|
| Sync_binlog| 0|
+----------------+-------+
6 rows in Set (0.00 sec)
You can also add parameters to the MY.CNF
General_log=1
General_log_file=/tmp/chenzhongyang.log this to set
Mysql> Show variables like "%file";
+---------------------+-----------------------------------------+
| variable_name| value|
+---------------------+-----------------------------------------+
| ft_stopword_file| (built-in) |
| general_log_file| /tmp/chenzhongyang.log|
| init_file| |
| local_infile| on|
| Pid_file|/usr/local/mysql/var/test4.wolf.org.pid |
| Relay_log_info_file | relay-log.info|
| Slow_query_log_file |/usr/local/mysql/var/test4-slow.log|
+---------------------+-----------------------------------------+
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/
Viewing the contents of a log file
[Root@test4 ~]# Tail-f/tmp/chenzhongyang.log
/usr/local/mysql/libexec/mysqld, Version:5.1.70-log (Source distribution). Started with:
TCP Port:3306unix Socket:/tmp/mysql.sock
Timeid CommandArgument
130903 16:09:431 Connectroot@localhost on
1 queryselect@ @version_comment Limit 1
130903 16:10:141 queryshow variables like "%file"
130903 16:12:091 Queryselect * FROMTT
130903 16:12:161 queryselect DATABASE ()
1 Init dbtest
130903 16:12:181 Queryselect * FROMTT
In general, we do not open the query log function, because he has a great impact on system efficiency
Managing Query log Files
General log files will be very large, so to process the log
[Root@test4 ~]# mysqladminflush-logs; refresh log all log files
Source: http://wolfword.blog.51cto.com/4892126/1287978