91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL 使用tee記錄語句和輸出日志

發布時間:2020-08-08 13:03:53 來源:ITPUB博客 閱讀:645 作者:feelpurple 欄目:MySQL數據庫
mysql命令行中,使用tee命令,可以記錄語句和輸出到指定文件。在debugging時會很有用。
每執行一條語句,mysql都會講執行結果刷新到指定文件。Tee功能只在交互模式生效。

mysql> tee /tmp/20160908.log

Logging to file '/tmp/20160908.log'
mysql> show databases;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    4
Current database: test

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.01 sec)

mysql> use test
Database changed
mysql> show tables;
+--------------------+
| Tables_in_test     |
+--------------------+
| ADDSubscribers     |
| Subscribers        |
| dept               |
| emp                |
| t10                |
| t2                 |
| t5                 |
| t50                |
| t7                 |
| test               |
| tmp_Subscribers_01 |
| tmp_Subscribers_02 |
| tmp_Subscribers_03 |
| version            |
+--------------------+
14 rows in set (0.00 sec)

mysql> select * from emp;
+-------+--------+-----------+------+---------------------+------+------+--------+
| empno | ename  | job       | mgr  | hiredate            | sal  | com  | deptno |
+-------+--------+-----------+------+---------------------+------+------+--------+
|  7369 | SMITH  | CLERK     | 7902 | 1980-12-17 00:00:00 |  800 | NULL |     20 |
|  7499 | ALLEN  | SALESMAN  | 7698 | 1981-02-20 00:00:00 | 1600 |  300 |     30 |
|  7521 | WARD   | SALESMAN  | 7698 | 1981-02-22 00:00:00 | 1250 |  500 |     30 |
|  7566 | JONES  | MANAGER   | 7839 | 1981-04-02 00:00:00 | 2975 | NULL |     20 |
|  7654 | MARTIN | SALESMAN  | 7698 | 1981-09-28 00:00:00 | 1250 | 1400 |     30 |
|  7698 | BLAKE  | MANAGER   | 7839 | 1981-05-01 00:00:00 | 2850 | NULL |     30 |
|  7782 | CLARK  | MANAGER   | 7839 | 1981-06-09 00:00:00 | 2450 | NULL |     10 |
|  7788 | SCOTT  | ANALYST   | 7566 | 1987-07-13 00:00:00 | 3000 | NULL |     20 |
|  7839 | KING   | PRESIDENT | NULL | 1981-11-17 00:00:00 | 5000 | NULL |     10 |
|  7844 | TURNER | SALESMAN  | 7698 | 1981-09-08 00:00:00 | 1500 |    0 |     30 |
|  7876 | ADAMS  | CLERK     | 7788 | 1987-07-13 00:00:00 | 1100 | NULL |     20 |
|  7900 | JAMES  | CLERK     | 7698 | 1981-12-03 00:00:00 |  950 | NULL |     30 |
|  7902 | FORD   | ANALYST   | 7566 | 1981-12-03 00:00:00 | 3000 | NULL |     20 |
|  7934 | MILLER | CLERK     | 7782 | 1982-01-23 00:00:00 | 1300 | NULL |     10 |
+-------+--------+-----------+------+---------------------+------+------+--------+
14 rows in set (0.03 sec)

使用notee命令來關閉日志記錄
mysql> notee
Outfile disabled.

查看生成的日志
[root@localhost fire]# cat /tmp/20160908.log
mysql> show databases;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    4
Current database: test

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.01 sec)

mysql> use test
Database changed
mysql> show tables;
+--------------------+
| Tables_in_test     |
+--------------------+
| ADDSubscribers     |
| Subscribers        |
| dept               |
| emp                |
| t10                |
| t2                 |
| t5                 |
| t50                |
| t7                 |
| test               |
| tmp_Subscribers_01 |
| tmp_Subscribers_02 |
| tmp_Subscribers_03 |
| version            |
+--------------------+
14 rows in set (0.00 sec)

mysql> select * from emp;
+-------+--------+-----------+------+---------------------+------+------+--------+
| empno | ename  | job       | mgr  | hiredate            | sal  | com  | deptno |
+-------+--------+-----------+------+---------------------+------+------+--------+
|  7369 | SMITH  | CLERK     | 7902 | 1980-12-17 00:00:00 |  800 | NULL |     20 |
|  7499 | ALLEN  | SALESMAN  | 7698 | 1981-02-20 00:00:00 | 1600 |  300 |     30 |
|  7521 | WARD   | SALESMAN  | 7698 | 1981-02-22 00:00:00 | 1250 |  500 |     30 |
|  7566 | JONES  | MANAGER   | 7839 | 1981-04-02 00:00:00 | 2975 | NULL |     20 |
|  7654 | MARTIN | SALESMAN  | 7698 | 1981-09-28 00:00:00 | 1250 | 1400 |     30 |
|  7698 | BLAKE  | MANAGER   | 7839 | 1981-05-01 00:00:00 | 2850 | NULL |     30 |
|  7782 | CLARK  | MANAGER   | 7839 | 1981-06-09 00:00:00 | 2450 | NULL |     10 |
|  7788 | SCOTT  | ANALYST   | 7566 | 1987-07-13 00:00:00 | 3000 | NULL |     20 |
|  7839 | KING   | PRESIDENT | NULL | 1981-11-17 00:00:00 | 5000 | NULL |     10 |
|  7844 | TURNER | SALESMAN  | 7698 | 1981-09-08 00:00:00 | 1500 |    0 |     30 |
|  7876 | ADAMS  | CLERK     | 7788 | 1987-07-13 00:00:00 | 1100 | NULL |     20 |
|  7900 | JAMES  | CLERK     | 7698 | 1981-12-03 00:00:00 |  950 | NULL |     30 |
|  7902 | FORD   | ANALYST   | 7566 | 1981-12-03 00:00:00 | 3000 | NULL |     20 |
|  7934 | MILLER | CLERK     | 7782 | 1982-01-23 00:00:00 | 1300 | NULL |     10 |
+-------+--------+-----------+------+---------------------+------+------+--------+
14 rows in set (0.03 sec)

mysql> notee

當調用mysql時,使用--tee參數,可以記錄這個登錄會話的全部日志。
[root@localhost ~]# mysql -uroot -p --tee=/tmp/20160908_02.log
Logging to file '/tmp/20160908_02.log'
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from test;
+------+-------+
| id   | name  |
+------+-------+
|   10 | neo   |
|   20 | John  |
|   30 | Lucy  |
|   40 | Larry |
|   50 | Lilly |
+------+-------+
5 rows in set (0.04 sec)

查看生成的日志
[root@localhost fire]# cat /tmp/20160908_02.log
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.31-77.0-log Percona Server (GPL), Release 77.0, Revision 5c1061c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from test;
+------+-------+
| id   | name  |
+------+-------+
|   10 | neo   |
|   20 | John  |
|   30 | Lucy  |
|   40 | Larry |
|   50 | Lilly |
+------+-------+
5 rows in set (0.04 sec)
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

辽中县| 新津县| 张家界市| 宝坻区| 新建县| 咸宁市| 青河县| 东乡族自治县| 乐亭县| 铁岭市| 合作市| 开江县| 万盛区| 达拉特旗| 甘德县| 章丘市| 深水埗区| 栾川县| 尼勒克县| 肥城市| 保山市| 福安市| 炉霍县| 泽库县| 鸡泽县| 张北县| 汤原县| 县级市| 贡嘎县| 昭苏县| 洛川县| 拉萨市| 万盛区| 浠水县| 望江县| 西乌| 九龙坡区| 蓬溪县| 海兴县| 新化县| 鄂托克旗|