MYSQL Query Logging
search cancel

MYSQL Query Logging

book

Article ID: 214602

calendar_today

Updated On:

Products

Network Flow Analysis Network Observability

Issue/Introduction

When working with support is is often useful to have a log of queries run on the MySQL database. Here is the procedure to turn mysql query logging on and off.

Environment

NFA All versions

Resolution

To enable Query Logging, run the following in a cmd prompt:

 

    Mysql -unetqos -pnetqos

 

Or (if you want to enable this for the Harvester’s custom mysql storage engine)

 

     Mysql -P3307 -unetqos -pnetqos

 

Mysql query logging will log ALL queries that are running in the background while it is enabled.

With NFA Services running it can log A LOT of output, so it should only be enabled for a short period of time.  

 

It is a helpful tool to find which tables are being updated during  a specific task or when loading a specific web page.  

To set the log file name:

     SET GLOBAL general_log_file='log.log';

 

To turn on the logging run the command below, I recommend having the task you want to trace ready to go before enabling it.

 

     set global general_log = 'ON';

 

Then reproduce whatever action you are trying to trace, then quickly run the command below to stop the query logging.

 

     set global general_log = 'OFF';



The log file will be in the \CA\NFA\Mysql\data\ directory.