How to Enable Genera Query Logging in MySQL Windows & Linux - MySQL DBA Tutorial

What is General Query Logging in MySQL Server and How to Enable it in MySQL Server


The General Query Log is used by the Server when the clients login and disconnect. It stores all SQL Statements run by the clients. It helps to debug errors as we can check what clients are sending to Server.

General Query Logging for MySQL in Windows:

If General Query logs are enabled without providing the location for General Query log file, then by default location for the General Query log will be "C:\ProgramData\MySQL\MySQL Server 8.0\Data" and file name will be "HostName.log".
To make change for General Query log file location and name , you can go to my.ini file on below path
"C:\ProgramData\MySQL\MySQL Server 8.0", Look for

general-log=0
general_log_file="HostName.log"


Change the value general-log=1 to enable it. if you would like to update the location for file, you can change in general-log-file=Folder Path/GeneralQueryLogFile.log


General Query Log File in Linux:


The default location for General Query log file for MySQL installed on Linux is /var/lib/MySQL. If you need to make changes to default location and binary file name, you can go to /etc/my.cnf file and update it. 
In case of default location, the name of the file will be "HostName.log". You can add below configuration to /etc/my.cnf to enable or disable General Query log.
general-log=0
general_log_file="/DirectoryPath/HostName.log"

Once you will make the changes, you will be restarting the MySQL service.

MySQL Logging Tutorial - What is General Query Logging and How to enable General Query Logging in Windows and Linux

No comments:

Post a Comment