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

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

[日期:2012-08-20] 来源:Linux社区  作者:521cto [字体:大 中 小]
MySQL> \T mysql_result.log
Logging to file 'mysql_result.log'
mysql> tee mysql_result.log
Logging to file 'mysql_result.log'
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| postfix            |
| test               |
| ucenter            |
| wordpress          |
| zabbix             |
+--------------------+
7 rows in set (0.00 sec)

mysql> show processlist;
+----+------+-----------+---------+---------+------+-------+------------------+
| Id | User | Host      | db      | Command | Time | State | Info             |
+----+------+-----------+---------+---------+------+-------+------------------+
|  4 | root | localhost | ucenter | Sleep   | 5564 |       | NULL             |
|  5 | root | localhost | NULL    | Query   |    0 | NULL  | show processlist |
+----+------+-----------+---------+---------+------+-------+------------------+
2 rows in set (0.01 sec)

mysql> \q
Bye
[root@ www.linuxidc.com ~]# cat mysql_result.log

mysql> tee mysql_result.log
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| postfix            |
| test               |
| ucenter            |
| wordpress          |
| zabbix             |
+--------------------+
7 rows in set (0.00 sec)

mysql> show processlist;
+----+------+-----------+---------+---------+------+-------+------------------+
| Id | User | Host      | db      | Command | Time | State | Info             |
+----+------+-----------+---------+---------+------+-------+------------------+
|  4 | root | localhost | ucenter | Sleep   | 5564 |       | NULL             |
|  5 | root | localhost | NULL    | Query   |    0 | NULL  | show processlist |
+----+------+-----------+---------+---------+------+-------+------------------+
2 rows in set (0.01 sec)

mysql> \q
[root@ www.linuxidc.com ~]# mysql --tee=mysql_result.log
Logging to file 'mysql_result.log'
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.45 Source distribution

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

mysql> show engines;
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                    | Transactions | XA   | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| CSV        | YES     | CSV storage engine                                         | NO           | NO   | NO         |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                      | NO           | NO   | NO         |
| FEDERATED  | NO      | Federated MySQL storage engine                             | NULL         | NULL | NULL       |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance     | NO           | NO   | NO         |
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables  | NO           | NO   | NO         |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.00 sec)

mysql> \q
Bye
[root@ www.linuxidc.com ~]# mysqladmin shutdown
[root@ www.linuxidc.com ~]# vim /usr/local/mysql/etc/my.cnf
[client]
tee             = /tmp/mysql_result.log
[root@ www.linuxidc.com ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --datadir=/data/mysql/data --user=mysql &
[1] 2620
[root@ www.linuxidc.com ~]# 120731 20:28:30 mysqld_safe Logging to '/data/mysql/data/tech.err'.
120731 20:28:30 mysqld_safe Starting mysqld daemon with databases from /data/mysql/data
[root@ www.linuxidc.com ~]# mysql
Logging to file '/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.

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

       

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