Chinaunix首页 | 论坛 | 博客
  • 博客访问: 243975
  • 博文数量: 103
  • 博客积分: 54
  • 博客等级: 民兵
  • 技术积分: 82
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-26 11:36
文章分类

全部博文(103)

文章存档

2016年(4)

2015年(91)

2014年(3)

2012年(5)

我的朋友

分类: Mysql/postgreSQL

2015-08-31 10:46:39

在用Oracle的SQL*PLUS的时候SPOOL真是好用啊.在MySQL中如何实现呢?下面来实验说明

MySQL中可以用tee参数具体实现方式有三种

第一种:tee参数加入my.cnf参数文件
例子:
tee =/mysql/mysql_op.log
注意:如果需要对client进行记录在[client]中加入

第二种:命令行
例子:
mysql -u root -p --tee=/mysql/mysql_op.log
这样会记录你的所有操作

第三章:
例子:
mysql> tee mysql_op.log
Logging to file 'mysql_op.log'
mysql> 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit
Bye
[mysql@localhost ~]$ ls
Desktop  Documents  Downloads  Music  mysql_op.log  Pictures  Public  Templates  Videos
[mysql@localhost ~]$ cat mysql_op.log 
mysql> 
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)
mysql> exit

关闭tee
mysql>notee
这种最类似于SQL*PLUS的SPOOL功能,将你命令行中的输出结果保存到外部文件中.如果指定已经存在的文件,则结果会附加到文件中.
阅读(850) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~