Reprint address: http://wasabi.iteye.com/blog/318962 MySQL has the following types of logs:
Error log:-log-err
Query log:-log
Slow query log:-log-slow-queries
Update log:-log-update
Binary log:-log-bin
Whether the log is enabled
Mysql>show variables like ' log_% ';
How to know the current log
Mysql> Show master status;
Show binary log Entries
Mysql> show master logs;
See binary log files 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 under C:\Windows.
The Linux:linux configuration file is my.cnf, usually in/etc.
Under Linux:
SQL code
- # Enter 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
- # Enter 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 how long the SQL executed 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 without using the indexed query
Log=mylog.log--Record all execution statements