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 logs are enabled
Mysql> show variables like 'Log _ % ';
How to know the current log
Mysql> show master status;
Displays binary log data
Mysql> show master logs;
Use mysqlbinlog to view binary log files
Shell> mysqlbinlog mail-bin.000001
Or shell> mysqlbinlog mail-bin.000001 | tail
Specify the log output location in the configuration file.
Windows: the configuration file for Windows is my. ini, which is usually in the MySQL installation directory or c:/Windows.
Linux: the configuration file of Linux is my. cnf, which is usually in/etc.
In linux:
SQL code
# Merge 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]
# Merge 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
Windows:
SQL code
# Merge 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]
# Merge 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"
Enable slow Query
Long_query_time = 2 -- indicates how long the SQL statement will be logged after execution. Here, it is 2 seconds.
Log-slow-queries =/usr/local/mysql/log/slowquery. log -- Records slow statements returned by the query.
Log-queries-not-using-indexes = nouseindex. log -- it is a literal meaning that the query with no index is used in the log.