{"id":15,"date":"2012-05-08T22:57:00","date_gmt":"2012-05-08T22:57:00","guid":{"rendered":"https:\/\/defragged.org\/ossec\/?p=15"},"modified":"2020-06-29T23:07:53","modified_gmt":"2020-06-29T23:07:53","slug":"database-logging-postgresql-and-mysql","status":"publish","type":"post","link":"https:\/\/defragged.org\/ossec\/2012\/05\/database-logging-postgresql-and-mysql\/","title":{"rendered":"Database Logging (PostgreSQL and MySQL)"},"content":{"rendered":"\n<p>Nobody cares about database logging, but I really recommend enabling them to see what is happening behind the scenes (specially for web applications).<\/p>\n\n\n\n<p><strong>To enable on PostgreSQL (and be compatible with OSSEC):<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Adding the timestamp, hostname and database.\nlog_line_prefix = '&#91;%m] %h:%d '\n\n# Recommended settings:\nlog_connections = on\nlog_disconnections = on\nlog_duration = on\n\n# Maybe a good idea to reduce the default log level to info:\nclient_min_messages = info\nlog_min_messages = info\n\n# To enable query logging (all for everything or mod for inserts, updates, etc)\nlog_statement = 'all'<\/code><\/pre>\n\n\n\n<p><strong>On MySQL:<\/strong><\/p>\n\n\n\n<p>To enable the generic Query log on MySQL (the error log in on by default), you need to start MySQL with \u2013log:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/bin\/sh \/usr\/bin\/mysqld_safe --log<\/code><\/pre>\n\n\n\n<p>The best option is to modify \/etc\/init.d\/mysqld (if using Centos) and inside the \u2013log in there.<\/p>\n\n\n\n<p>Nothing new, but I was searching for this information online and couldn\u2019t find much info.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nobody cares about database logging, but I really recommend enabling them to see what is happening behind the scenes (specially for web applications). To enable on PostgreSQL (and be compatible with OSSEC): On MySQL: To enable the generic Query log on MySQL (the error log in on by default), you need to start MySQL with [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":1,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":16,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/posts\/15\/revisions\/16"}],"wp:attachment":[{"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/defragged.org\/ossec\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}