mysql查询日志

1.查看查询日志配置

mysql> show variables like 'general_log%';
+------------------+------------------+
| Variable_name    | Value            |
+------------------+------------------+
| general_log      | ON               |
| general_log_file | /tmp/general.log |
+------------------+------------------+
2 rows in set (0.00 sec)

mysql> show variables like 'log_output%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_output    | FILE  |
+---------------+-------+
1 row in set (0.00 sec)


2.修改
mysql> set global general_log=0;
Query OK, 0 rows affected (0.01 sec)


mysql> show variables like 'general_log%';
+------------------+------------------+
| Variable_name    | Value            |
+------------------+------------------+
| general_log      | OFF              |
| general_log_file | /tmp/general.log |
+------------------+------------------+
2 rows in set (0.00 sec)

或者编辑/etc/my.cnf
general_log=on
log_output=file
general_log_file='/tmp/general.log'

3.查看查询日志内容

150817  1:55:05     1 Query     desc user
150817  1:55:21     1 Query     select user,machine,password from user where user='root'
150817  1:55:39     1 Query     select user,host,password from user where user='root'
150817  1:56:00     1 Quit
150817  1:56:06     2 Connect   root@localhost on
                    2 Query     select @@version_comment limit 1
150817  1:56:10     2 Quit
150817  1:56:15     3 Connect   a@localhost as  on
                    3 Query     select @@version_comment limit 1
150817  1:56:16     3 Quit
150817  1:56:20     4 Connect   root@localhost on
                    4 Query     select @@version_comment limit 1
150817  1:56:30     4 Query     SELECT DATABASE()
                    4 Init DB   mysql
                    4 Query     show databases
                    4 Query     show tables
                    4 Field List        columns_priv
                    4 Field List        db
                    4 Field List        event
                    4 Field List        func
                    4 Field List        general_log
                    4 Field List        help_category
                    4 Field List        help_keyword

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-1775189/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10972173/viewspace-1775189/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值