Locate MySQL Log Files on macOS

macOS Database

If you are using macOS, you can use the following SQL statements to find your MySQL logs:

SHOW VARIABLES LIKE '%general_log%';
SHOW VARIABLES LIKE '%slow_query_log%';

The output should look something like this:

general_log            ON
general_log_file       /usr/local/mysql/data/localhost.log
slow_query_log         ON
slow_query_log_file    /usr/local/mysql/data/localhost-slow.log

Now, you can use tail to display the latest 100 entries, for example:

tail -f -n 100 /usr/local/mysql/data/localhost.log

Enabling Logs

If your logs are disabled, you can enable them using the following two statements:

SET GLOBAL general_log = 'ON';
SET GLOBAL slow_query_log = 'ON';