当前位置:嗨网首页>书籍在线阅读

10-日志的读取

  
选择背景色: 黄橙 洋红 淡粉 水蓝 草绿 白色 选择字体: 宋体 黑体 微软雅黑 楷体 选择字体大小: 恢复默认

因为查询日志记录的格式是纯文本,所以可以直接进行读取。下面是一个读取查询日志的例子。

(1)首先在客户端对数据库做一些简单操作,包括查询和插入。

mysql> use test

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select * from dept;

Empty set (0.00 sec)

mysql> insert into emp values(1,'z2');

Query OK, 1 row affected (0.01 sec)

(2)然后查看查询日志中记录的客户端的所有操作,对应的内容如下:

[root@localhost mysql]# more localhost.log

070810 6:52:02 9 Query select * from dept

070810 6:52:27 9 Query insert into emp values(1,'z2')

070810 6:53:50 9 Quit

注意:log日志中记录了所有数据库的操作,对于访问频繁的系统,此日志对系统性能的影响较大,建议一般情况下关。