/*The first step is to create the following two log tables*/ 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( One) not NULL, ' rows_examined 'int( One) not NULL, ' DB 'varchar( +) not NULL, ' last_insert_id 'int( One) not NULL, ' insert_id 'int( One) not NULL, ' server_id 'int(Ten) unsigned not NULL, ' Sql_text ' Mediumtext not NULL, ' thread_id 'bigint( +) unsigned not NULL) ENGINE=CsvDEFAULTCHARSET=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( +) unsigned not NULL, ' server_id 'int(Ten) unsigned not NULL, ' Command_type 'varchar( -) not NULL, ' argument ' Mediumtext not NULL) ENGINE=CsvDEFAULTCHARSET=UTF8 COMMENT='General Log'; /*The second step is to open the query log on the database*/ SETGlobal General_log= 1;SETGlobal Log_output= 'Table'; /*Step three query log*/Select * fromMysql.general_log; /*Step Fourth closes the query log on the database*/SETGlobal General_log= 0; /*Fifth Step clear the database log*/truncate TableMysql.general_log;
MySQL Event Tracker