Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2111672
  • 博文数量: 195
  • 博客积分: 4378
  • 博客等级: 上校
  • 技术积分: 4046
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-09 11:37
个人简介

白天和黑夜只交替没交换无法想像对方的世界

文章分类

全部博文(195)

文章存档

2014年(3)

2013年(20)

2012年(18)

2011年(107)

2010年(17)

2009年(5)

2008年(20)

2007年(5)

分类: Mysql/postgreSQL

2013-12-13 09:47:53

在用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功能,将你命令行中的输出结果保存到外部文件中.如果指定已经存在的文件,则结果会附加到文件中.
阅读(5488) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

airmy2013-12-13 09:49:36

文明上网,理性发言...转载需要收费哦..哈哈哈哈