8

I have a problem with the mysql query-log.

I searched the used my.cnf with https://stackoverflow.com/a/2896718/1012683 and added the line log=/var/log/mysqld_query.log to my.cnf. Then I restartet mysql but there is still no query-log.

Whats wrong here?

Thanks, Flo

Community
  • 1
  • 1
sbo
  • 951
  • 2
  • 12
  • 25

2 Answers2

21

You need to set general_log to 'ON'. see here

Add this in my.cnf and then restart MySQL server:

general_log = 1
log=/var/log/mysqld_query.log

or

SET GLOBAL general_log = 'ON';
stovroz
  • 6,835
  • 2
  • 48
  • 59
Omesh
  • 27,801
  • 6
  • 42
  • 51
  • it works! i've done SET GLOBAL general_log = 'ON' and SET GLOBAL general_log_file = '/var/log/mysqld_query.log' – sbo Aug 08 '12 at 09:32
  • where is my my.cnf? http://stackoverflow.com/questions/2482234/how-to-know-mysql-my-cnf-location – thicolares Jul 29 '15 at 12:51
3

You can check whether the general_log is 'ON' or 'OFF' first using query:

mysql>show variables like '%log%';

if the general_log is 'OFF', then the setting of log=... will not work. The general_log can be turn on when mysql is running (do not need to restart mysql) using cmd below:

mysql>SET GLOBAL general_log = 'ON';

And the log file in variable general_log_file will be auto generated.

zhihong
  • 1,808
  • 2
  • 24
  • 34