Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1916500
  • 博文数量: 498
  • 博客积分: 2078
  • 博客等级: 大尉
  • 技术积分: 1645
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-18 22:43
个人简介

安大

文章分类

全部博文(498)

文章存档

2017年(1)

2016年(2)

2015年(21)

2014年(90)

2013年(101)

2012年(267)

2011年(16)

分类: Mysql/postgreSQL

2013-12-13 12:49:04

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