|
+----------+
| 1 |
+----------+
--查看通用日志文件内容
root@localhost[(none)]> system more /tmp/suse11b.log
mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
141003 16:30:03 1 Query show variables like '%gener%'
141003 16:30:09 1 Query select count(*) from tempdb.tb1
c、通用查询日志输出方式
--可以输出为文件,表以及不输出,即TABLE,FILE,NONE
--系统变量log_output
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | FILE |
+---------------+-------+
--下面修改为输出为表方式
root@localhost[(none)]> set global log_output='TABLE';
Query OK, 0 rows affected (0.00 sec)
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | TABLE |
+---------------+-------+
--发布查询
root@localhost[(none)]> select * from tempdb.tb1;
+------+------+
| id | val |
+------+------+
| 1 | jack |
+------+------+
--Author: Leshami
--Blog : http://blog.csdn.net/leshami
root@localhost[(none)]> system more /tmp/suse11b.log
mysqld, Version: 5.5.39-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
141003 16:30:03 1 Query show variables like '%gener%'
141003 16:30:09 1 Query select count(*) from tempdb.tb1
141003 16:31:00 1 Query show variables like 'log_output'
141003 17:00:48 1 Query set global log_output='TABLE' #通用查询日志输出到文件仅仅记录到全局变量的修改
--mysql.general_log记录了通用查询日志的信息
root@localhost[(none)]> desc mysql.general_log;
+--------------+------------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------------------+------+-----+-------------------+-----------------------------+
| event_time | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| user_host | mediumtext | NO | | NULL | |
| thread_id | int(11) | NO | | NULL | |
| server_id | int(10) unsigned | NO | | NULL | |
| command_type | varchar(64) | NO | | NULL | |
| argument | mediumtext | NO | | NULL | |
+--------------+------------------+------+-----+-------------------+-----------------------------+
--从通用查询日志表里查看通用查询日志的内容
root@localhost[(none)]> select thread_id,command_type,argument from mysql.general_log;
+-----------+--------------+---------------------------------------------------------------+
| thread_id | command_type | argument |
+-----------+--------------+---------------------------------------------------------------+
| 1 | Query | show variables like 'log_output' |
| 1 | Query | select * from tempdb.tb1 |
| 1 | Query | desc mysql.general_log |
| 1 | Query | select thread_id,command_type,argument from mysql.general_log |
+-----------+--------------+---------------------------------------------------------------+
root@localhost[(none)]> show variables like 'log_output';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output | TABLE |
+---------------+-------+
--使用FILE,TABLE 2者混合输出通用日志
root@localhost[(none)]> set global log_output='file, |