Monday, December 26, 2022

Where can I find the MySQL log file in XAMPP - Activate logs in Xampp-Mysql

I use PHP (PDO) to access MySQL in XAMPP. My question is where I can find the MySQL query log, exact query that executed on MySQL server?
You need to run these two queries:

SET GLOBAL general_log = 'ON';

SET GLOBAL general_log_file = 'my_log.log';
First will enable loging (which may be off by default)

and the second select updates the preferred file (by default under C:/xampp/mysql/data/)
NOTE: On windows 8 you may have to run your SQL IDE as ADMINISTRATOR for this commands to get saved.
You can also set this in the config, go to path_to_xampp/mysql/ and edit my.ini (copy from my-default.ini if it does not exists) and add the settings there:
[mysqld]

general_log = 'ON';
general_log_file = 'my_log.log';

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
You can view your query logs like below window:
Step1: You need to install Git Bash
Step2: Open Git Bash terminal and navigate to xampp_install_directory/mysql/data directory
Step3: Run command tail -f my_log.log


No comments:

Post a Comment