国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql查看sql語句執行歷史記錄的實例

2024-07-24 12:35:27
字體:
來源:轉載
供稿:網友
  下面來為各位介紹一個mysql查看sql語句執行歷史記錄的例子,如果你希望跟蹤你程序的執行性能我們就可以使用下面方法,有需要了解的朋友可進入看看.
 
  mysql查看sql語句執行歷史記錄:
 
  cat ~/.mysql_history
 
  對于mysql版本5.1以后的版本,可以通過以下方式啟動日志記錄,能夠記錄下包括應用程序執行的sql語句.
 
  MariaDB [(none)]> SET GLOBAL log_output = 'TABLE';
  Query OK, 0 rows affected (0.02 sec)
  MariaDB [(none)]> SET GLOBAL general_log = 'ON';
  Query OK, 0 rows affected (0.00 sec)
  MariaDB [(none)]> show databases;
  +--------------------+
  | Database |
  +--------------------+
  | information_schema |
  | gfan_log |
  | gfan_pay |
  | gfanpg |
  | gfanrc |
  | mysql |
  | performance_schema |
  | ucenter |
  +--------------------+
  8 rows in set (0.02 sec)
  MariaDB [(none)]> use mysql
  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
  MariaDB [mysql]> show tables;
  +---------------------------+
  | Tables_in_mysql |
  +---------------------------+
  | columns_priv |
  | db |
  | event |
  | func |
  | general_log |
  | help_category |
  | help_keyword |
  | help_relation |
  | help_topic |
  | host |
  | ndb_binlog_index |
  | plugin |
  | proc |
  | procs_priv |
  | proxies_priv |
  | servers |
  | slow_log |
  | tables_priv |
  | time_zone |
  | time_zone_leap_second |
  | time_zone_name |
  | time_zone_transition |
  | time_zone_transition_type |
  | user |
  +---------------------------+
  24 rows in set (0.00 sec)
  MariaDB [mysql]> select * from general_log limit 10;
  +----------------------------+---------------------------+-----------+-----------+--------------+-------------------+
  | event_time | user_host | thread_id | server_id | command_type | argument |
  +----------------------------+---------------------------+-----------+-----------+--------------+-------------------+
  | 2014-11-12 14:29:49.810999 | root[root] @ localhost [] | 1304 | 0 | Query | show databases |
  | 2014-11-12 14:29:51.951747 | root[root] @ localhost [] | 1304 | 0 | Query | SELECT DATABASE() |
  | 2014-11-12 14:29:51.973180 | root[root] @ localhost [] | 1304 | 0 | Init DB | mysql |
  | 2014-11-12 14:29:51.975048 | root[root] @ localhost [] | 1304 | 0 | Query | show databases |
  | 2014-11-12 14:29:51.975689 | root[root] @ localhost [] | 1304 | 0 | Query | show tables |
  | 2014-11-12 14:29:51.976347 | root[root] @ localhost [] | 1304 | 0 | Field List | columns_priv |  --phpfensi.com
  | 2014-11-12 14:29:51.976800 | root[root] @ localhost [] | 1304 | 0 | Field List | db |
  | 2014-11-12 14:29:51.977431 | root[root] @ localhost [] | 1304 | 0 | Field List | event |
  | 2014-11-12 14:29:51.978052 | root[root] @ localhost [] | 1304 | 0 | Field List | func |
  | 2014-11-12 14:29:51.978224 | root[root] @ localhost [] | 1304 | 0 | Field List | general_log |
  +----------------------------+---------------------------+-----------+-----------+--------------+-------------------+
  10 rows in set (0.01 sec)
  MariaDB [mysql]>
  
  If you want to output to the log file:
  SET GLOBAL log_output = “FILE”;
  SET GLOBAL general_log_file = “/path/to/your/logfile.log”
  SET GLOBAL general_log = ‘ON’;
  Restart MySQL to apply the changes if you edit the config, e.g. /etc/mysql/my.cnf
  Now, if you’d like you can tail -f /var/log/mysql/mysql.log。

(編輯:武林網)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武乡县| 宝应县| 东至县| 庆安县| 泗阳县| 济南市| 灵丘县| 资阳市| 壶关县| 孝昌县| 平罗县| 正宁县| 务川| 突泉县| 喀喇沁旗| 临夏市| 泰顺县| 新平| 铁力市| 新宾| 项城市| 方山县| 马边| 洪泽县| 山阴县| 大埔区| 舟山市| 英德市| 罗城| 武邑县| 江山市| 辛集市| 奉化市| 哈巴河县| 吉安县| 油尖旺区| 阿巴嘎旗| 辽中县| 淮北市| 蓬莱市| 敖汉旗|