0

我正在使用 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. */
4

2 回答 2

1

您可以启用general_log,重新启动服务器,一小时后将其禁用(因为它会影响性能并且文件可能会变大)并再次重新启动

于 2012-12-14T08:42:51.097 回答
0

我相信mysql历史文件是你要找的?.mysql_history在您的数据库用户主目录中查找。

要访问该.mysql_history文件,请运行此命令 - cat ~/.mysql_history。如果当前用户不是数据库用户,则需要 cd 进入数据库用户的主目录,然后运行cat .mysql_history​​.

您使用的是哪个操作系统,用于数据库?

于 2012-12-14T07:22:57.160 回答