Log is very important to a system or application, troubleshooting or resolving faults, the first time is to look at the error log
MySQL Log classification: Log files record the various types of activities affecting the database, MySQL database common log file classification.
Error log--If the log does not exist, flush logs card master, if you want to back up the error log, you must re-create a new one, and give permission to execute the flush logs;
Slow query logs (Slow query log)--If the log does not exist, flush logs will indicate that the log file does not exist and will not be created, if you want to back up the slow query log, you must re-create a new one, and give permission to execute the flush logs;
Binary logs (binary log)--Generate a new binary file
Query log (general_log)--if it does not exist, MySQL automatically generates a
Note: When you execute flush logs, the MySQL instance will close and reopen the log file
Second, error log details: MySQL error log is to record the operation of MySQL more serious warnings and error messages, as well as MySQL each time the startup and shutdown detailed information.
"See where the MySQL database error log is stored"
Mysql> Show variables like ' log_error ';
+---------------+---------------------+
| variable_name | Value |
+---------------+---------------------+
| Log_error | /var/log/mysqld.log |
+---------------+---------------------+
1 row in Set (0.01 sec)
My.cnf
Log-error=/var/log/mysqld.log--or some of the differences shown in the MySQL instance
Impersonation error log:
Three, slow query log
Parameters related to the slow query log:
Slow_query_log=on|off #是否开启慢查询日志
Slow_query_log_file=filepathandname; #指定慢查询日志文件的路径和文件名, default in the data directory
Long_query_time=5 #指定多少秒没有返回结果的语句记录日志, that is, more than that time is considered a slow query
Log_queries_not_using_indexes #记录所有没有使用到索引的查询语句
min_examined_row_limit=1000 #记录由于查询了多于1000次而导致的慢查询
Log_slow_admin_statements #记录慢的那些OPTIMIZE table, Analze table, and ALTER TABLE statements. Because queries are executed internally by these statements, such as alert table will be queried first before being modified.
Log_slow_slave_statements #记录由slave所产生的慢查询
log_output=file| TABLE #如果选择table SELECT * from Mysql.slow_log;
Set parameters:
SET @ @global. log_output= ' FILE ';
Set global log_output= ' TABLE ';
SELECT @ @log_output;
SELECT @ @global. log_output;
Show global variables like ' log_output ';
Show variables like ' log_output ';
?
Analog Slow query log: Select Sleep ()
MySQL Log system