{"id":2796,"date":"2018-07-05T15:40:53","date_gmt":"2018-07-05T07:40:53","guid":{"rendered":"http:\/\/blg.sofasay.com\/?p=2796"},"modified":"2018-07-05T15:49:38","modified_gmt":"2018-07-05T07:49:38","slug":"%e6%9f%a5%e7%9c%8b%e6%95%b0%e6%8d%ae%e5%ba%93%e6%93%8d%e4%bd%9c%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"http:\/\/blog.sofasay.com\/?p=2796","title":{"rendered":"\u67e5\u770b\u6570\u636e\u5e93\u64cd\u4f5c\u65e5\u5fd7"},"content":{"rendered":"<p>\u628a\u6240\u6709\u5bf9\u6570\u636e\u5e93\u7684\u64cd\u4f5c\/SQL(DDL,DML,Query)\u5168\u90fd\u8bb0\u5f55\u5230\u6587\u4ef6\u6216\u8005\u8868\u4e2d\uff0c\u7528\u4e8e\u8c03\u8bd5\u6216\u67e5\u9519\u3002<\/p>\n<h5>Mysql<\/h5>\n<p>\u8f6c\u81ea\uff1a <a href=\"https:\/\/alanli7991.github.io\/2016\/07\/28\/MySQL%E6%9F%A5%E7%9C%8B%E6%95%B0%E6%8D%AE%E5%BA%93%E6%93%8D%E4%BD%9C%E8%AE%B0%E5%BD%95\/\">Link<\/a><\/p>\n<p>\u9996\u5148\u8fdb\u5165mysql\u8f93\u5165\u6307\u4ee4<\/p>\n<blockquote><p>show variables like &#8216;gen%&#8217;;<\/p>\n<pre><\/pre>\n<\/blockquote>\n<p>\u53ef\u4ee5\u770b\u5230\u8f93\u51fa<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<pre><\/pre>\n<p>| Variable_name | Value |<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<p>| general_log | OFF |<\/p>\n<p>| general_log_file | \/usr\/local\/mysql\/data\/localhost.log |<\/p>\n<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<\/p>\n<pre><\/pre>\n<p>\u53ef\u4ee5\u770b\u5230general_log\u662f\u5f00\u542f\u8fd8\u662f\u73af\u6bd4\u72b6\u6001\uff0c\u4ee5\u53ca\u8fd9\u4e2a\u5e10\u53f7\u7684general_log\u6587\u4ef6\u5728\u54ea\uff0c\u8bbe\u7f6e\u5f00\u542f<\/p>\n<blockquote><p>set global general_log=ON;<\/p>\n<p>commit;\/\/\u5982\u679c\u5173\u95ed\u4e86\u81ea\u52a8\u63d0\u4ea4\uff0c\u8bb0\u5f97commit\u4e00\u6b21\u7ed3\u675f\u4e8b\u52a1<\/p>\n<pre><\/pre>\n<\/blockquote>\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u53bbgeneral_log_file\u7684\u8def\u5f84\u67e5\u770b\u64cd\u4f5c\u8bb0\u5f55\u4e86<\/p>\n<h4><\/h4>\n<h4>\u91c7\u7528\u6570\u636e\u5e93\u5185\u90e8\u67e5\u770b<\/h4>\n<p>\u51fa\u4e86\u53ef\u4ee5\u7528\u65e5\u5fd7\u6587\u4ef6\u7684\u5f62\u5f0f\u67e5\u770b\u6570\u636e\u5e93\u64cd\u4f5c\u8bb0\u5f55\u4e4b\u5916\uff0c\u4e5f\u53ef\u4ee5\u628a\u65e5\u5fd7\u4f5c\u4e3a\u4e00\u4e2a\u8868\u5355\uff0c\u5728\u6570\u636e\u5e93\u5185\u90e8\u67e5\u770b<\/p>\n<blockquote><p>show variables like &#8216;%log_output%&#8217;;<\/p>\n<pre><\/pre>\n<\/blockquote>\n<p>\u53ef\u4ee5\u770b\u5230\u8f93\u51fa\uff0c\u7136\u540e\u5c06\u5176\u6539\u4e3a\u8868\u5355<\/p>\n<pre>+---------------+-------+<\/pre>\n<pre>| Variable_name | Value |<\/pre>\n<pre>+---------------+-------+<\/pre>\n<pre>| log_output    | FILE  |<\/pre>\n<pre>+---------------+-------+<\/pre>\n<blockquote><p>set global log_output=&#8217;TABLE&#8217;;<\/p><\/blockquote>\n<pre><\/pre>\n<p>\u4e4b\u540e\u5c31\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u4e24\u53e5\u8bdd\u67e5\u770b\u6570\u636e\u5e93\u64cd\u4f5c\u8bb0\u5f55<\/p>\n<blockquote><p>select * from mysql.general_log; &lt;=====\u67e5\u770b\u64cd\u4f5c\u8bb0\u5f55<\/p>\n<p>truncate table mysql.general_log; &lt;=====\u6e05\u7a7a\u64cd\u4f5c\u8bb0\u5f55\u8868\u5355<\/p>\n<pre><\/pre>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<h5>Postgresql<\/h5>\n<p>\u8f93\u51fa\u65e5\u5fd7\u5230\u6587\u4ef6\uff0c\u4fee\u6539$PGDATA\/postgresql.conf\u00a0\u00a0 \u53ef\u80fd$PGDATA=\/var\/lib\/pgsql\/9.4\/data<\/p>\n<p>log_destination = &#8216;stderr&#8217;<\/p>\n<p>logging_collector = on<\/p>\n<p>log_directory = &#8216;pg_log&#8217;<\/p>\n<p>log_filename = &#8216;postgresql-%a.log&#8217;<\/p>\n<p>#log_filename = &#8216;postgresql-%Y-%m-%d_%H%M%S.log&#8217;<\/p>\n<p>log_statement = &#8216;mod&#8217;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # none, ddl, mod, all<\/p>\n<p>\u65e5\u5fd7\u6587\u4ef6\u53ea\u8bb0\u5f55\u6570\u636e\u66f4\u65b0\u7684\u64cd\u4f5c,\u6587\u4ef6\u540d\u5982\u4e0b<\/p>\n<p>-rw&#8212;&#8212;-. 1 postgres postgres\u00a0 129 Jun 29 17:00 postgresql-Fri.log<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h5>\u5982\u4f55\u67e5\u770b<\/h5>\n<p>Linux\u4e0b:<\/p>\n<ul>\n<li>\u7528 tail -f &lt;logfilename&gt; \u6765\u6301\u7eed\u663e\u793a\u6700\u65b0log<\/li>\n<\/ul>\n<p>Windows\u4e0b:<\/p>\n<ul>\n<li>\u4e0b\u8f7d tail.exe \u653e\u5230 c:\/windows\u76ee\u5f55\u4e0b \u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/files.cnblogs.com\/hantianwei\/tail.zip\">\/Files\/hantianwei\/tail.zip<\/a><\/li>\n<li>\u6216\u8005\u4f7f\u7528GUI\u5de5\u5177, BareTail: <a href=\"http:\/\/www.baremetalsoft.com\/baretail\/index.php\">http:\/\/www.baremetalsoft.com\/baretail\/index.php<\/a> \u53ef\u4ee5\u9ad8\u4eae\u5173\u952e\u5b57,\u6bd4tail\u547d\u4ee4\u53cb\u597d.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u628a\u6240\u6709\u5bf9\u6570\u636e\u5e93\u7684\u64cd\u4f5c\/SQL(DDL,DML,Query)\u5168\u90fd\u8bb0\u5f55\u5230\u6587\u4ef6\u6216\u8005\u8868\u4e2d\uff0c\u7528\u4e8e\u8c03\u8bd5\u6216\u67e5\u9519\u3002 Mysql &hellip; <a href=\"http:\/\/blog.sofasay.com\/?p=2796\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u67e5\u770b\u6570\u636e\u5e93\u64cd\u4f5c\u65e5\u5fd7\u201d<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[13,464],"tags":[470,469],"views":730,"_links":{"self":[{"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=\/wp\/v2\/posts\/2796"}],"collection":[{"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2796"}],"version-history":[{"count":0,"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=\/wp\/v2\/posts\/2796\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2796"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.sofasay.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}