Contents

Sometimes we need to enable the MySQL log to see what SQL scripts have been created by our application. This is a way to enable MySQL log.

  1. Login to mysql in command line
  2. Run the scripts below:
1
2
3
4
/* For Mac OS */
SET global log_output = 'FILE';
SET global general_log_file='/Applications/MAMP/logs/mysql_general.log';
SET global general_log = 1;
1
2
3
4
/* For Linux */
SET global log_output = 'FILE';
SET global general_log_file='/var/log/mysql/mysql_general.log';
SET global general_log = 1;

It can be turned off with:

1
SET global general_log = 0;
Contents