zoukankan      html  css  js  c++  java
  • MySQL 事件跟踪器

      /*第一步 创建以下两个 日志表 */
      
      CREATE TABLE `slow_log` (
       `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP 
                              ON UPDATE CURRENT_TIMESTAMP,
       `user_host` mediumtext NOT NULL,
       `query_time` time NOT NULL,
       `lock_time` time NOT NULL,
       `rows_sent` int(11) NOT NULL,
       `rows_examined` int(11) NOT NULL,
       `db` varchar(512) NOT NULL,
       `last_insert_id` int(11) NOT NULL,
       `insert_id` int(11) NOT NULL,
       `server_id` int(10) unsigned NOT NULL,
       `sql_text` mediumtext NOT NULL,
       `thread_id` bigint(21) unsigned NOT NULL
      ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log';
      
      CREATE TABLE `general_log` (
       `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
                              ON UPDATE CURRENT_TIMESTAMP,
       `user_host` mediumtext NOT NULL,
       `thread_id` bigint(21) unsigned NOT NULL,
       `server_id` int(10) unsigned NOT NULL,
       `command_type` varchar(64) NOT NULL,
       `argument` mediumtext NOT NULL
      ) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log';
      
    /*第二步 在数据库上开启 查询日志 */
      
    SET global general_log = 1;
    SET global log_output = 'table';
     
    /*第三步 查询日志 */
    select * from mysql.general_log;
    
      
    /*第四步 在数据库上关闭 查询日志 */
    
    SET global general_log = 0;
    
     
    
    /*第五步 清除数据库 日志 */
    
    truncate table mysql.general_log;
  • 相关阅读:
    sql 数据库还原脚本 (kill链接+独占
    最长回文字符串
    UVa 455 Periodic Strings
    UVa 1225 Digit Counting
    UVa 340 Master-Mind Hints
    UVa 10976
    UVa 725
    UVa 11059
    POJ1887 最长下降子序列
    最大连续子序列算法(数组的连续子数组最大和(首尾不相连))
  • 原文地址:https://www.cnblogs.com/liaojie970/p/4802068.html
Copyright © 2011-2022 走看看