To enable query log in mysql execute the below steps:
First of all we need to locate my.ini file where we can set the variables for mysql server.
my.ini file will reside at path "C:\ProgramData\MySQL\MySQL Server 5.*\"
--permanent changes
Open file in editor (notepad, npp , editplus any of one) and look for below variables
--Temporary changes
show variables like '%log_file%';
note down file name
set global log-output='FILE';
set global slow-query-log=1;
set global long_query_time=2;
Note:
same Queries can be used in linux and the path to log file is "var/lib/mysql"
First of all we need to locate my.ini file where we can set the variables for mysql server.
my.ini file will reside at path "C:\ProgramData\MySQL\MySQL Server 5.*\"
--permanent changes
Open file in editor (notepad, npp , editplus any of one) and look for below variables
Default setting of variables:-
# General and Slow logging.
log-output=NONE
general-log=0
general_log_file="machine_name.log"
slow-query-log=0
slow_query_log_file="machine_name-slow.log"
long_query_time=2
# General and Slow logging.
log-output=NONE
general-log=0
general_log_file="machine_name.log"
slow-query-log=0
slow_query_log_file="machine_name-slow.log"
long_query_time=2
# General and Slow logging.
log-output=FILE
[enable all type of logging, Can also set to TABLE]
general-log=0
[Set it to 1 , to enable it]
general_log_file="machine_name.log"
[any filename, default path "C:\ProgramData\MySQL\MySQL Server 5.*\data"]
slow-query-log=1
[Set it to 1 , to enable it]
slow_query_log_file="machine_name-slow.log"
[any filename, default path "C:\ProgramData\MySQL\MySQL Server 5.*\data"]
long_query_time=2
[slow query time, query will logged into file if it take >2 sec]
log-output=FILE
[enable all type of logging, Can also set to TABLE]
general-log=0
[Set it to 1 , to enable it]
general_log_file="machine_name.log"
[any filename, default path "C:\ProgramData\MySQL\MySQL Server 5.*\data"]
slow-query-log=1
[Set it to 1 , to enable it]
slow_query_log_file="machine_name-slow.log"
[any filename, default path "C:\ProgramData\MySQL\MySQL Server 5.*\data"]
long_query_time=2
[slow query time, query will logged into file if it take >2 sec]
--Temporary changes
show variables like '%log_file%';
note down file name
set global log-output='FILE';
set global slow-query-log=1;
set global long_query_time=2;
Note:
same Queries can be used in linux and the path to log file is "var/lib/mysql"
very helpful
ReplyDelete