Bye
suse11b:~ # service mysql stop
Shutting down MySQL... done
suse11b:~ # mysqld --general_log_file=/tmp/suse11b.log --user=mysql &
[1] 47009
suse11b:~ # ps -ef|grep mysql|grep -v grep
mysql 47009 44514 1 16:22 pts/0 00:00:00 mysqld --general_log_file=/tmp/suse11b.log --user=mysql
root 47053 44514 0 16:22 pts/0 00:00:00 grep mysql
suse11b:~ # mysql
root@localhost[(none)]> system ls /tmp/suse11b.log
ls: cannot access /tmp/suse11b.log: No such file or directory
root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+
| Variable_name | Value |
+------------------+------------------+
| general_log | OFF |
| general_log_file | /tmp/suse11b.log |
+------------------+------------------+
root@localhost[(none)]> set global general_log=on;
Query OK, 0 rows affected (0.01 sec)
--此时从系统变量看出,通用日志已经到/tmp目录下
root@localhost[(none)]> show variables like '%gener%';
+------------------+------------------+
| Variable_name | Value |
+------------------+------------------+
| general_log | ON |
| general_log_file | /tmp/suse11b.log |
+------------------+------------------+
--发布查询
root@localhost[(none)]> select count(*) from tempdb.tb1;
+----------+
| count(*) |
+----------+
| 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)