sql - How do I enable the MySQL slow query log? -
this question has answer here:
my mysql version details are
- server: localhost via unix socket
- software: mysql
- software version: 5.0.96-community-log - mysql community edition (gpl)
- protocol version: 10
how enable mysql slow query log?
version 5.1.6 , above:
1. enter mysql shell , run following command:
set global slow_query_log = 'on';
2. enable other desired options. here common examples:
log details queries expected retrieve rows instead of using index:
set global log_queries_not_using_indexes = 'on'
set path slow query log:
set global slow_query_log_file ='/var/log/mysql/slow-query.log';
set amount of time query needs run before being logged:
set global long_query_time = '20'; (default 10 seconds)
3. confirm changes active entering mysql shell , running following command:
show variables '%slow%';
versions below 5.1.6:
edit /etc/my.cnf file favorite text editor vi /etc/my.cnf
add following line under “[mysqld]” section. feel free update path log file whatever want:
log-slow-queries=/var/log/mysql/slow-query.log
3. enable additional options needed. here same commonly used examples above:
set amount of time query needs run before being logged:
`long_query_time=20 (default 10 seconds)`
log details queries expected retrieve rows instead of using index:
`log-queries-not-using-indexes`
4. restart mysql service:
service mysqld restart
5. confirm change active entering mysql shell , running following:
show variables '%slow%';
update:1
according mysql docs, error #1193 occurs when use wrong code sqlstate.
message: unknown system variable %s
and, can see on same page, sqlstate 99003 not defined.
refer link:
Comments
Post a Comment