{"id":1823,"date":"2020-07-09T13:05:05","date_gmt":"2020-07-09T20:05:05","guid":{"rendered":"https:\/\/jim-zimmerman.com\/?p=1823"},"modified":"2020-07-09T13:05:05","modified_gmt":"2020-07-09T20:05:05","slug":"mysql-mariadb-logging-to-a-table","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=1823","title":{"rendered":"MySQL\/MariaDB logging to a table"},"content":{"rendered":"<p>OS: CentOS 7<br \/>\nThere are a few ways to enable query logging in MariaDB.  I did it by editing the server.cnf file.  <\/p>\n<blockquote><p># cd \/etc\/my.cnf.d<br \/>\nvi server.cnf<br \/>\n&#8230;<br \/>\n[mariadb]<br \/>\nlog_output=TABLE<br \/>\ngeneral_log<br \/>\n&#8230;<\/p><\/blockquote>\n<p>Restart mariadb:<\/p>\n<blockquote><p># systemctl restart mariadb<\/p><\/blockquote>\n<p>The output is put in the mysql.general_log table.  Fortunately, I had used unique userid for each of my applications.  This allowed me to be able to query the table to find those queries for a particular database.  For example, an application using dbuser for database access:<\/p>\n<blockquote><p>MariaDB [mysql]> SELECT * FROM general_log WHERE user_host like &#8216;%dbuser%localhost%&#8217;;<\/p><\/blockquote>\n<p>You are going to want to truncate this log once in a while, because it will get very large depending the on the activity.<\/p>\n<blockquote><p>MariaDB [mysql]> TRUNCATE mysql.general_log<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>OS: CentOS 7 There are a few ways to enable query logging in MariaDB. I did it by editing the server.cnf file. # cd \/etc\/my.cnf.d vi server.cnf &#8230; [mariadb] log_output=TABLE general_log &#8230; Restart mariadb: # systemctl restart mariadb The output is put in the mysql.general_log table. Fortunately, I had used unique userid for each of [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[440,497,248],"class_list":["post-1823","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-log","tag-mariadb","tag-mysql"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1823"}],"version-history":[{"count":1,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1823\/revisions"}],"predecessor-version":[{"id":1824,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1823\/revisions\/1824"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}