sajad torkamani

Enable logging

Locate your mysql.cnf file and add the following configuration options.

general_log = on
general_log_file =/tmp/mysql.log # or whatever path you want                                        

Restart your MySQL server (how you do this will depend on your platform and installation method).

Tail the log file


tail -f /tmp/mysql.log

Do some stuff in your app that triggers SQL queries and the SQL queries should then show up in your terminal as something like:

2023-08-20T11:07:35.248658Z        11 Connect   root@localhost on symfony_demo_app using TCP/IP
2023-08-20T11:07:35.250345Z        11 Query     SELECT AS id_0, a0_.title AS title_1, a0_.content AS content_2 FROM article a0_ WHERE a0_.title = 'Article 1' AND a0_.content = 'Foo' AND a0_.title = 'Article 1'
2023-08-20T11:07:35.278938Z        11 Quit      
Tagged: MySQL