- Error log: Errors logs
- Query log: Querying logs General Query Log/slow query LOG: Statements that have exceeded the set time (Long_query_time) or have not gone through the index
- Binary log: Binary logs that record information about the data being modified
Open query log (usually not open):
Mysql>Show variables like 'general_log%';+------------------+---------------------------+|Variable_name|Value|+------------------+---------------------------+|General_log| on ||General_log_file| /Data/3307/Data/Mysql.Log |+------------------+---------------------------+
2 rows in Set (0.00 sec)
Slow query parameters
Long_query_time=1 #查询超过1秒钟的
Slow_query_log_file =/data/3307/log/mysql-slow.log #日志路径
Log_queries_not_using_indexes #没使用索引的语句
Slow_query_log = 1
Binary log
Mysql>Show variables like '%log_bin%';+---------------------------------+---------------------------------+|Variable_name|Value|+---------------------------------+---------------------------------+|Log_bin| on ||Log_bin_basename| /Data/3307/Data/Mysql-Bin||Log_bin_index| /Data/3307/Data/Mysql-Bin.Index ||Log_bin_trust_function_creators| OFF ||Log_bin_use_v1_row_events| OFF ||Sql_log_bin| on |+---------------------------------+---------------------------------+6Rowsinch Set(0.00Sec
Error log
Log_error =/data/3307/log/mysql-error.log
Binary log three modes of operation:
1, Statement level:
Each SQL that modifies the data is recorded in the Bin-log of master, and slave the SQL process resolves the same SQL that sing Woo the original master side to execute
Advantages: Solve the disadvantage of the row level, do not need to record each row of data changes, reduce the Bin-log log volume, save IO, only the SQL and contextual information executed on the master
Cons: There are many situations where replication problems occur, in the use of functions, stored procedures, etc.
2. Row level
The log is recorded in the form of each row of data being modified, and then the same data is modified on the slave side
Advantage: Do not log the execution of SQL context information, only record which row is modified, you can resolve the stored procedure, Function,trigger calls and triggers cannot be correctly copied problems.
Cons: Record a statement change each row, the log volume is large, especially when the table structure changed.
3, Mixed
Depending on the execution of each specific SQL to distinguish between the format of the log, such as encountering a table structure changes, and so on, will use the statement level mode, if the SQL statement update,delete and other modified data statements, will record all row changes.
Mysql>Mysql>Show variables like '%binlog_format%';+---------------+-------+|Variable_name|Value|+---------------+-------+|Binlog_format|ROW|+---------------+-------+1Rowinch Set(0.00Sec
Configuration file Modification:
Binlog_format=statement,row,mixed
Session level Modification: Set session binlog_format= "STATEMENT", "ROW", "MIXED"
Global level modification: Set global binlog_format= "STATEMENT", "ROW", "MIXED"
Following this command, you can parse the Binlog in row mode into statement mode
[Email protected] data]# Mysqlbinlog--base64-output=decode-rows-v mysql-bin.000006
Mysql>Show variables like '%binlog_format%';+---------------+-----------+|Variable_name|Value|+---------------+-----------+|Binlog_format|STATEMENT|+---------------+-----------+1Rowinch Set(0.00Sec
Mysql> Set session binlog_format= "Row";
Query OK, 0 rows Affected (0.00 sec)
Mysql>
Mysql>
Mysql> Show variables like '%binlog_format% ';
+---------------+-------+
| variable_name | Value |
+---------------+-------+
| Binlog_format | ROW |
+---------------+-------+
1 row in Set (0.01 sec)
Mysqlbinlog---Bin-log logs for parsing MySQL
Mysqlbinlog mysql-bin.0000001--start-position=234--stop-position=345-r full.sql
Log of MySQL