我正在使用mysql-xampp !!
我基本上想要监视一小时的所有查询,并将日志转储到文件中。
如何将我输入的过去一小时的查询记录到文本文件中?
有可能吗?
粘贴了过去一小时使用的查询。
SHOW CREATE TABLE `hr_test`.`auction`;
SHOW CREATE TABLE `hr_test`.`auction_log`;
SHOW CREATE TABLE `hr_test`.`error_log`;
SELECT `timestamp`, `username`, `instance`, `database_name`, `error_stack` FROM `hr_test`.`error_log` LIMIT 1000;
SHOW CREATE TABLE `hr_test`.`error_log`;
SELECT `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`='information_schema';
SHOW TABLE STATUS FROM `information_schema`;
SHOW FUNCTION STATUS WHERE `Db`='information_schema';
SHOW PROCEDURE STATUS WHERE `Db`='information_schema';
SHOW TRIGGERS FROM `information_schema`;
SHOW EVENTS FROM `information_schema`;
SELECT `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`='performance_schema';
SHOW TABLE STATUS FROM `performance_schema`;
SHOW FUNCTION STATUS WHERE `Db`='performance_schema';
SHOW PROCEDURE STATUS WHERE `Db`='performance_schema';
SHOW TRIGGERS FROM `performance_schema`;
SHOW EVENTS FROM `performance_schema`;
/* SQL Error (1044): Access denied for user 'pma'@'192.168.1.69' to database 'performance_schema' */
SELECT `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`='phpmyadmin';
SHOW TABLE STATUS FROM `phpmyadmin`;
SHOW FUNCTION STATUS WHERE `Db`='phpmyadmin';
SHOW PROCEDURE STATUS WHERE `Db`='phpmyadmin';
SHOW TRIGGERS FROM `phpmyadmin`;
SHOW EVENTS FROM `phpmyadmin`;
USE `phpmyadmin`;
SHOW CREATE TABLE `phpmyadmin`.`pma_tracking`;
SELECT `db_name`, `table_name`, `version`, `date_created`, `date_updated`, LEFT(`schema_snapshot`, 256), LEFT(`schema_sql`, 256), LEFT(`data_sql`, 256), `tracking`, `tracking_active` FROM `phpmyadmin`.`pma_tracking` LIMIT 1000;
SHOW CREATE TABLE `phpmyadmin`.`pma_tracking`;
SELECT `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`='system_audit';
SHOW TABLE STATUS FROM `system_audit`;
SHOW FUNCTION STATUS WHERE `Db`='system_audit';
SHOW PROCEDURE STATUS WHERE `Db`='system_audit';
SHOW TRIGGERS FROM `system_audit`;
SHOW EVENTS FROM `system_audit`;
USE `system_audit`;
SHOW CREATE TABLE `system_audit`.`systeminformation`;
SELECT `Machine_Name`, `Serial_Number`, `System_Manufacturer`, `System_Model`, `Motherboard_Manufacturer`, `Motherboard_Model`, `Chassis_Type`, `System_Type`, `Physical_Memory`, `RAM_Capacity`, `RAM_Slots`, `BIOS_Description`, `BIOS_Date`, `CENTRAL PROCESSING UNIT (CPU)`, `CPU_Type` FROM `system_audit`.`systeminformation` LIMIT 1000;
SHOW CREATE TABLE `system_audit`.`systeminformation`;
SELECT `Machine_Name`, `Serial_Number`, `System_Manufacturer`, `System_Model`, `Motherboard_Manufacturer`, `Motherboard_Model`, `Chassis_Type`, `System_Type`, `Physical_Memory`, `RAM_Capacity`, `RAM_Slots`, `BIOS_Description`, `BIOS_Date`, `CENTRAL PROCESSING UNIT (CPU)`, `CPU_Type` FROM `system_audit`.`systeminformation` LIMIT 1000;
SHOW CREATE TABLE `system_audit`.`systeminformation`;
USE `phpmyadmin`;
SELECT `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`='mysql';
SHOW TABLE STATUS FROM `mysql`;
SHOW FUNCTION STATUS WHERE `Db`='mysql';
SHOW PROCEDURE STATUS WHERE `Db`='mysql';
SHOW TRIGGERS FROM `mysql`;
SHOW EVENTS FROM `mysql`;
USE `mysql`;
SHOW CREATE TABLE `mysql`.`time_zone_transition`;
SELECT `Time_zone_id`, `Transition_time`, `Transition_type_id` FROM `mysql`.`time_zone_transition` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`time_zone_transition`;
SHOW TABLE STATUS LIKE 'time_zone_transition';
SHOW CREATE TABLE `mysql`.`time_zone_transition_type`;
SELECT `Time_zone_id`, `Transition_type_id`, `Offset`, `Is_DST`, `Abbreviation` FROM `mysql`.`time_zone_transition_type` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`time_zone_transition_type`;
SHOW TABLE STATUS LIKE 'time_zone_transition_type';
SELECT `Time_zone_id`, `Transition_type_id`, `Offset`, `Is_DST`, `Abbreviation` FROM `mysql`.`time_zone_transition_type` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`time_zone_transition_type`;
SHOW TABLE STATUS LIKE 'time_zone_transition_type';
SHOW CREATE TABLE `mysql`.`help_topic`;
SELECT `help_topic_id`, `name`, `help_category_id`, LEFT(`description`, 256), LEFT(`example`, 256), `url` FROM `mysql`.`help_topic` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`help_topic`;
SELECT `help_topic_id`, `name`, `help_category_id`, LEFT(`description`, 256), LEFT(`example`, 256), `url` FROM `mysql`.`help_topic` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`help_topic`;
SHOW CREATE TABLE `mysql`.`help_keyword`;
SELECT `help_keyword_id`, `name` FROM `mysql`.`help_keyword` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`help_keyword`;
SELECT `help_keyword_id`, `name` FROM `mysql`.`help_keyword` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`help_keyword`;
SHOW CREATE TABLE `mysql`.`help_category`;
SELECT `help_category_id`, `name`, `parent_category_id`, `url` FROM `mysql`.`help_category` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`help_category`;
SELECT `help_category_id`, `name`, `parent_category_id`, `url` FROM `mysql`.`help_category` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`help_category`;
SHOW CREATE TABLE `mysql`.`general_log`;
SELECT `event_time`, `user_host`, `thread_id`, `server_id`, `command_type`, `argument` FROM `mysql`.`general_log` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`general_log`;
SELECT `event_time`, `user_host`, `thread_id`, `server_id`, `command_type`, `argument` FROM `mysql`.`general_log` LIMIT 1000;
SHOW CREATE TABLE `mysql`.`general_log`;
SHOW VARIABLES LIKE '%log_file%';
/* 0 rows affected, 4 rows found. Duration for 1 query: 0.000 sec. */
答案 0 :(得分:1)
您可以启用general_log,重新启动服务器,一小时后将其禁用(因为它会影响性能并且文件可能会变大)并重新启动
答案 1 :(得分:0)
我相信mysql history file正是您要找的?在数据库用户主目录中查找.mysql_history
。
要访问.mysql_history
文件,请运行此命令 - cat ~/.mysql_history
。如果当前用户不是数据库用户,则需要cd到数据库用户的主目录,然后运行cat .mysql_history
。
您使用的是哪个操作系统,用于数据库?