How To View Live MYSQL Queries

Here’s a simple trick for viewing MySQL queries as they hit your server – enable query logging to a file and then tail -f the file:

mysql> SHOW VARIABLES LIKE "general_log%";
| Variable_name | Value |
| general_log | OFF |
| general_log_file | /opt/local/var/db/mysql56/out.log |
2 rows in set (0.00 sec)
mysql> SET GLOBAL general_log = 'ON';
Query OK, 0 rows affected (0.01 sec)

view raw


hosted with ❤ by GitHub

tail -f /opt/local/var/db/mysql56/out.log

view raw

hosted with ❤ by GitHub

Just be sure to turn it off when you’re done:

mysql> SET GLOBAL general_log = 'OFF';

view raw


hosted with ❤ by GitHub

One thought on “How To View Live MYSQL Queries”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s