在用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功能,將你命令行中的輸出結果保存到外部文件中.如果指定已經存在的文件,則結果會附加到文件中.
全站熱搜
留言列表