Thursday, March 12, 2015

How to enable Mysql general log

1. Using mysql table as the general log:

a. Log on MySQL using superuser.

SET global general_log = 1;
SET global log_output = 'table';

b. Query general log table.

select * from mysql.general_log 
where event_time between '2015-03-11 22:52:40' and '2015-03-13 22:52:40'
and argument not like '%mysql.general_log%' order by event_time;

2. Using a file as the general log:

a. Create an empty log file which can be written by mysql user.

touch /var/log/mysql_general_log
chown mysql:mysql /var/log/mysql_general_log

b. Log on MySQL using superuser.

SET global general_log_file='/var/log/mysql_general_log';
SET global general_log = 1;

c. Query general log file

tail -100f /var/log/mysql_general_log


No comments:

Post a Comment