Monitor MySQL queries


Local

SET GLOBAL log_output = "FILE";
SET GLOBAL general_log_file = "mysql-queries.log";
SET GLOBAL general_log = 'ON';

Then you can tail -f the log file.

It will be in the mysql datadir (SELECT @@GLOBAL.datadir). This is /opt/homebrew/var/mysql/ on my Mac.

In theory you can use an absolute path, but you’ll need to worry about permissions.

Remote

SET GLOBAL log_output = 'TABLE';
SET GLOBAL general_log = 'ON';
SELECT * FROM mysql.general_log

source

Date: 2024-04-25

Tags:  mysql

Share: