How to log queries in real time using MariaDB/MySQL


You have some sticky queries but you can’t see what’s happening. On certain website actions pages are just slow and you fully suspect the database queries are broken. Or you want to reverse engineer another piece of software’s database queries.


How you can turn on MySQL query logging. Go into the MySQL console and do:

SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file = '/tmp/mysql.log';

Keep the console open, because when you’re done you want to set the “ON” above back to “OFF”.

Open another terminal and do:

tail -f /tmp/mysql.log



Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top