设为首页 加入收藏

TOP

MySQL通用查询日志(GeneralQueryLog)(二)
2015-07-24 11:32:17 来源: 作者: 【 】 浏览:8
Tags:MySQL 通用 查询 日志 GeneralQueryLog
+----------+ | 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,
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇解决mysql控制台查询数据乱码的问.. 下一篇mysql多日志表结果集合拼接存储过..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·nginx 监听一个端口 (2025-12-25 00:19:30)
·整个互联网就没有一 (2025-12-25 00:19:27)
·囧次元最新官网入口 (2025-12-25 00:19:24)
·如何利用Python做数 (2025-12-24 23:48:36)
·如何使用python进行 (2025-12-24 23:48:34)