To see if logging is enabled
Copy Code code as follows:
Mysql>show variables like ' log_bin ';
How to know the current log
Copy Code code as follows:
Mysql> Show master status;
Show number of binary logs
Copy Code code as follows:
See binary log file with Mysqlbinlog
Copy Code code as follows:
Shell>mysqlbinlog mail-bin.000001
Or
Copy Code code as follows:
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.
Log File Types Overview:
1. Error logging issues that occur when you start, run, or stop mysqld.
My.ini configuration information:
Copy Code code as follows:
#Enter a name for the error log file. Otherwise a default name would be used.
#log-error=d:/mysql_log_err.txt
2. Query log records established client connections and executed statements.
My.ini configuration information:
Copy Code code as follows:
#Enter a name for the query log file. Otherwise a default name would be used.
#log =d:/mysql_log.txt
3. Update the statement in which the log records changes data. The use of this log is not supported.
My.ini configuration information:
Copy Code code as follows:
#Enter a name for the update log file. Otherwise a default name would be used.
#log-update=d:/mysql_log_update.txt
4. The binary log records all statements that change data. Also used for replication.
My.ini configuration information:
Copy Code code as follows:
#Enter a name for the binary log. Otherwise a default name would be used.
#log-bin=d:/mysql_log_bin
5. A slow log records all queries that have an execution time exceeding long_query_time seconds, or queries that do not use indexes.
My.ini configuration information:
Copy Code code as follows:
#Enter a name for the slow query log file. Otherwise a default name would be used.
#long_query_time =1
#log-slow-queries= D:/mysql_log_slow.txt
Linux under:
Input in [mysqld]
Copy Code code as follows:
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
Input in [mysqld]
Copy Code code as follows:
# #启动日志
Log= "E:/wamp/mysql/mysql_log/mysql.log"
# #错误日志
Log-error= "E:/wamp/mysql/mysql_log/mysql.logerror.log"
# #是指执行超过多久的sql会被log下来, this is 2 seconds.
long_query_time=2
# #慢查询日志
Log-slow-queries= "E:/wamp/mysql/mysql_log/slowquery.log"
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
Log=mylog.log--Record all execution statements