mysql中使用tee实现类似oracle spool功能
2015-11-17 18:12
786 查看
在mysql中我们可以通过tee来实现类似oracle 中spool的功能,实现方式有如下三种:
1.在/etc/my.cnf中的[client]部分加入类似如下内容
tee =/root/tee.log
##这样在新的客户端登录数据库时就会记录他所有的操作
执行show databases;操作后查看tee.log
vi /root/tee.log
2.在登录的时候指定--tee参数
3.登录mysql后执行tee命令
1.在/etc/my.cnf中的[client]部分加入类似如下内容
tee =/root/tee.log
##这样在新的客户端登录数据库时就会记录他所有的操作
mysql -uroot -p -S /tmp/mysql3306.sock Logging to file '/root/tee.log' <span style="color:#ff0000;"> >>已经生成了日志</span> Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.27-log Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
执行show databases;操作后查看tee.log
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | shao | | test | +--------------------+ 5 rows in set (0.00 sec)
vi /root/tee.log
vi /root/tee.log
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.27-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | shao | | test | +--------------------+ 5 rows in set (0.00 sec)
2.在登录的时候指定--tee参数
mysql -uroot -p -S /tmp/mysql3306.sock --tee=/root/tee.log
Logging to file '/root/tee.log' <span style="color:#ff0000;">>>生成日志</span>
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.27-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | shao | | test | +--------------------+ 5 rows in set (0.00 sec)
3.登录mysql后执行tee命令
mysql> tee /root/tee.log Logging to file '/root/tee.log' mysql> show variables like 'port'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.00 sec) mysql>查看日志
vi tee.log mysql> show variables like 'port'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | port | 3306 | +---------------+-------+ 1 row in set (0.00 sec)
相关文章推荐
- Retrieve Oracle password from Toad for Oracle
- Oracle11.2新特性之listagg函数 (行列转换)
- navicat连接oracle数据库报ORA-28547: connection to server failed, probable Oracle Net admin error错误的解决方法
- JDBC链接MySQL和Oracle
- Installing PHP and the Oracle Instant Client for Linux and Windows For PHP 5.5, OCI8 2.0 and Oracle
- Oracle 错误总结及问题解决 ORA
- oracle 左右内和完全链接
- 创建表
- ORACLE常用SQL优化hint语句
- 关于Oracle ADF 11g的VO处理
- oracle clob 存储大于4000字符的字符串
- Oracle外键级联删除和级联更新
- Oracle 中 decode 函数用法
- oracle中判断"非"
- Linux 下Oracle 手工create database 脚本和步骤
- Java笔记oracle--SQL基础篇(一)
- 查看及修改Oracle编码格式方法
- Oracle使用DBSTART开机启动
- Oracle 常用命令
- Oracle中执行update语句时卡住的解决方法