|
@@ -0,0 +1,34 @@
|
|
|
+---
|
|
|
+title: Database Query Logging
|
|
|
+categories: [cheatsheets]
|
|
|
+tags: [topic]
|
|
|
+---
|
|
|
+
|
|
|
+# Database Query Logging
|
|
|
+
|
|
|
+## MySQL & MariaDB
|
|
|
+
|
|
|
+* Uncomment the following lines in the MySql configuration file:
|
|
|
+
|
|
|
+```
|
|
|
+general_log_file = /var/log/mysql/mysql.log
|
|
|
+general_log = 1
|
|
|
+```
|
|
|
+
|
|
|
+* File location: `/etc/mysql/my.conf`
|
|
|
+* Restart SQL: `systemctl restart mysql`
|
|
|
+* Watch Logs: `sudo tail -f /var/log/mysql/mysql.log`
|
|
|
+
|
|
|
+
|
|
|
+## Postgresql
|
|
|
+
|
|
|
+* Change the `log_statement` to `all`, as seen below:
|
|
|
+
|
|
|
+```
|
|
|
+log_statement = 'all' # none, ddl, mod, all
|
|
|
+```
|
|
|
+
|
|
|
+* File location Windows: `<application>\pgsql\data\<db>\postgresql.conf`
|
|
|
+* File location Linux: `/etc/postgresql/<version>/main/postgresql.conf`
|
|
|
+
|
|
|
+
|