How to show the last queries executed on MySQL?

User Avatar
👤 admin
🔴 Admin
✍️ The most important thing in the world is to not be alone.
⏳ Last active: 15 Apr 2025 at 16:01
📅 Created: 11 Feb 2021 at 12:04
👀 Viewed: 22 times
✉️ Send Email

You can enable a general query log for that sort of diagnostic. Generally you don't log all SELECT queries on a production server though, it's a performance killer.
Edit your MySQL config, e.g. /etc/mysql/my.cnf - look for, or add, a line like this:


[mysqld]

log = /var/log/mysql/mysql.log

Restart mysql to pick up that change, now you can:


tail -f /var/log/mysql/mysql.log


Hey presto, you can watch the queries as they come in.

If you want to comment: Login or Register