linux\u73af\u5883\u4e0b<\/strong><\/div>\nMySQL\u4e2d\u7684\u53c2\u6570general_log\u7528\u6765\u63a7\u5236\u5f00\u542f\u3001\u5173\u95edMySQL\u67e5\u8be2\u65e5\u5fd7,\u53c2\u6570general_log_file\u7528\u6765\u63a7\u5236\u67e5\u8be2\u65e5\u5fd7\u7684\u4f4d\u7f6e\u3002\u6240\u4ee5\u5982\u679c\u4f60\u8981\u5224\u65adMySQL\u6570\u636e\u5e93\u662f\u5426\u5f00\u542f\u4e86\u67e5\u8be2\u65e5\u5fd7\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u3002general_log\u4e3aON\u8868\u793a\u5f00\u542f\u67e5\u8be2\u65e5\u5fd7\uff0cOFF\u8868\u793a\u5173\u95ed\u67e5\u8be2\u65e5\u5fd7\u3002<\/p>\n
\r\nmysql> show variables like '%general_log%';\r\n+------------------+------------------------------+\r\n| Variable_name | Value |\r\n+------------------+------------------------------+\r\n| general_log | OFF |\r\n| general_log_file | \/var\/lib\/mysql\/DB-Server.log |\r\n+------------------+------------------------------+\r\n2 rows in set (0.00 sec)\r\n<\/pre>\n\u53e6\u5916\uff0cMySQL\u7684\u67e5\u8be2\u65e5\u5fd7\u652f\u6301\u5199\u5165\u6587\u4ef6\u6216\u5199\u5165\u6570\u636e\u8868\u4e24\u79cd\u5f62\u5f0f\uff0c\u8fd9\u4e2a\u7531\u53c2\u6570log_output\u63a7\u5236\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n
\r\nmysql> show variables like 'log_output';\r\n+---------------+-------+\r\n| Variable_name | Value |\r\n+---------------+-------+\r\n| log_output | FILE |\r\n+---------------+-------+\r\n1 row in set (0.00 sec)\r\n \r\n<\/pre>\n\u5f00\u542fMySQL\u67e5\u8be2\u65e5\u5fd7<\/strong><\/span><\/div>\n\r\nmysql> set global general_log = on;\r\nQuery OK, 0 rows affected (0.11 sec)\r\n \r\nmysql> show variables like 'general_log';\r\n+---------------+-------+\r\n| Variable_name | Value |\r\n+---------------+-------+\r\n| general_log | ON |\r\n+---------------+-------+\r\n1 row in set (0.02 sec)\r\n \r\n<\/pre>\n\u5173\u95edMySQL\u67e5\u8be2\u65e5\u5fd7<\/strong><\/span><\/div>\n\r\nmysql> show variables like 'general_log';\r\n+---------------+-------+\r\n| Variable_name | Value |\r\n+---------------+-------+\r\n| general_log | ON |\r\n+---------------+-------+\r\n1 row in set (0.01 sec)\r\n \r\nmysql> set global general_log=off;\r\nQuery OK, 0 rows affected (0.01 sec)\r\n \r\nmysql> show variables like 'general_log';\r\n+---------------+-------+\r\n| Variable_name | Value |\r\n+---------------+-------+\r\n| general_log | OFF |\r\n+---------------+-------+\r\n1 row in set (0.00 sec)\r\n \r\n<\/pre>\n\u8bbe\u7f6e\u65e5\u5fd7\u8f93\u51fa\u65b9\u5f0f\u4e3a\u8868<\/strong><\/span><\/div>\n\u5982\u679c\u8bbe\u7f6elog_output=table\u7684\u8bdd\uff0c\u5219\u65e5\u5fd7\u7ed3\u679c\u4f1a\u8bb0\u5f55\u5230\u540d\u4e3agengera_log\u7684\u8868\u4e2d\uff0c\u8fd9\u8868\u7684\u9ed8\u8ba4\u5f15\u64ce\u662fCSV\uff09\u3002<\/p>\n
\r\nmysql> show variables like 'log_output';\r\n+---------------+-------+\r\n| Variable_name | Value |\r\n+---------------+-------+\r\n| log_output | FILE |\r\n+---------------+-------+\r\n1 row in set (0.00 sec)\r\n \r\nmysql> set global log_output='table';\r\nQuery OK, 0 rows affected (0.00 sec)\r\n \r\nmysql> show variables like 'log_output';\r\n+---------------+-------+\r\n| Variable_name | Value |\r\n+---------------+-------+\r\n| log_output | TABLE |\r\n+---------------+-------+\r\n1 row in set (0.01 sec)\r\n \r\n<\/pre>\n\u67e5\u770b\u67e5\u8be2\u65e5\u5fd7\u4fe1\u606f\u3002<\/strong><\/span><\/div>\n\r\nmysql> select * from mysql.general_log;\r\n+---------------------+---------------------------+-----------+-----------+--------------+----------------------------------+\r\n| event_time | user_host | thread_id | server_id | command_type | argument |\r\n+---------------------+---------------------------+-----------+-----------+--------------+----------------------------------+\r\n| 2017-07-06 12:32:05 | root[root] @ localhost [] | 1 | 1 | Query | show variables like 'general%' |\r\n| 2017-07-06 12:32:28 | root[root] @ localhost [] | 1 | 1 | Query | show variables like 'log_output' |\r\n| 2017-07-06 12:32:41 | root[root] @ localhost [] | 1 | 1 | Query | select * from MyDB.test |\r\n| 2017-07-06 12:34:36 | [root] @ localhost [] | 3 | 1 | Connect | root@localhost on |\r\n| 2017-07-06 12:34:36 | root[root] @ localhost [] | 3 | 1 | Query | KILL QUERY 1 |\r\n| 2017-07-06 12:34:36 | root[root] @ localhost [] | 3 | 1 | Quit | |\r\n| 2017-07-06 12:34:51 | root[root] @ localhost [] | 1 | 1 | Query | select * from mysql.general_log |\r\n+---------------------+---------------------------+-----------+-----------+--------------+----------------------------------+\r\n7 rows in set (0.02 sec)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"\u627e\u5230my.ini,\u5728\u4e0b\u9762\u6dfb\u52a0\uff1a log=\u5b58\u653e\u65e5\u5fd7\u7684\u8def\u5f84\/my.log \u4fdd\u5b58\u6587\u4ef6\uff0c\u91cd\u542fmysql\u670d\u52a1\uff0c\u4e4b\u540e\u5c31\u53ef\u4ee5 […]<\/p>\n","protected":false},"author":1903,"featured_media":110423,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-204242","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=204242"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204242\/revisions"}],"predecessor-version":[{"id":204244,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/204242\/revisions\/204244"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/110423"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=204242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=204242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=204242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}