手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

详解MySQL的tee功能 并利用其记录相关操作

[日期:2012-08-20] 来源:Linux社区  作者:521cto [字体:大 中 小]

MySQL> \s
--------------
mysql  Ver 14.14 Distrib 5.1.45, for pc-linux-gnu (i686) using readline 5.1

Connection id:          1
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          '/tmp/mysql_result.log'
Using delimiter:        ;
Server version:         5.1.45 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /tmp/mysql.sock
Uptime:                 37 sec

Threads: 1  Questions: 4  Slow queries: 0  Opens: 17  Flush tables: 1  Open tables: 4  Queries per second avg: 0.108
--------------

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.1.45    |
+-----------+
1 row in set (0.00 sec)

mysql> \q
Bye
[root@ www.linuxidc.com ~]# ll /tmp/mysql_result.log
-rw-r--r-- 1 root root 932 Jul 31 20:29 /tmp/mysql_result.log
[root@ www.linuxidc.com ~]# more /tmp/mysql_result.log
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> \s
--------------

Connection id:          1
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          '/tmp/mysql_result.log'
Using delimiter:        ;
Server version:         5.1.45 Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /tmp/mysql.sock
Uptime:                 37 sec

Threads: 1  Questions: 4  Slow queries: 0  Opens: 17  Flush tables: 1  Open tables: 4  Queries per second avg: 0.108
--------------

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.1.45    |
+-----------+
1 row in set (0.00 sec)

mysql> \q

通过以下来关闭mysql的tee功能:
mysql> \t
Outfile disabled.
或者
mysql> notee
Outfile disabled.

针对不同版本的mysql可能有所差异,本次测试用的mysql数据库版本是5.1.45,本人也亲自测试了,5.1.45 和5.1.56都没有问题,有些版本的mysql数据库的tee功能在写入配置文件的时候不生效,但是支持终端下命令行直接操作,例如:4.0.26和5.1.60,目前还不清楚原因何在,猜测也有可能是某些版本存在bug,有知道原因的读者请多赐教,深表感谢!!!

linux
相关资讯       MySQL基础教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款