MySQL has the following several logs:
Error log:-log-err
Query log:-log
Slow query log:-log-slow-queries
Update log:-log-update
Binary log:-log-bin
Whether logging is enabled
Mysql>show variables like ' log_% ';
How to know the current log
Mysql> Show master status;
Display binary Log numbers
Mysql> show master logs;
See binary log file with Mysqlbinlog
Shell>mysqlbinlog mail-bin.000001
or Shell>mysqlbinlog mail-bin.000001 | Tail
Specify the output location of the log in the configuration file.
The windows:windows configuration file is My.ini, usually under the MySQL installation directory or c:/windows.
The Linux:linux configuration file is my.cnf, usually under/etc.
Under Linux:
SQL code
# input in [mysqld]
#log
Log-error=/usr/local/mysql/log/error.log
Log=/usr/local/mysql/log/mysql.log
long_query_time=2
log-slow-queries=/usr/local/mysql/log/slowquery.log
[SQL]
# input in [mysqld]
#log
Log-error=/usr/local/mysql/log/error.log
Log=/usr/local/mysql/log/mysql.log
long_query_time=2
log-slow-queries=/usr/local/mysql/log/slowquery.log
Under Windows:
SQL code
# input in [mysqld]
#log
Log-error= "E:/progra~1/easyph~1.0b1/mysql/logs/error.log"
Log= "E:/progra~1/easyph~1.0b1/mysql/logs/mysql.log"
long_query_time=2
Log-slow-queries= "E:/progra~1/easyph~1.0b1/mysql/logs/slowquery.log"
[SQL]
# input in [mysqld]
#log
Log-error= "E:/progra~1/easyph~1.0b1/mysql/logs/error.log"
Log= "E:/progra~1/easyph~1.0b1/mysql/logs/mysql.log"
long_query_time=2
Log-slow-queries= "E:/progra~1/easyph~1.0b1/mysql/logs/slowquery.log"
Turn on Slow query
Long_query_time = 2--refers to the execution of more than how long SQL will be log down, here is 2 seconds
log-slow-queries=/usr/local/mysql/log/slowquery.log--Log the query back to a slower statement
Log-queries-not-using-indexes = nouseindex.log--literally, log down. Query with no index