Mysqlbinlog:
Used to parse Binlog logs. Under the data directory, Mysql.index is the index file for Mysqlbinlog. The role of Binlog is to record internal MySQL deletions. Do not record select.
Options:
1.-d dbname: For the library, split the binary log of the specified library
2.--start-position;--stop-position mysqldump mysql-bin.000006--start-position=486--stop-position=1156 > Test.sql
Master-data=
When it is 2 o'clock, the Master_log_pos line will be commented out, and when it is 1 o'clock, the Master_log_pos line will not be commented.
is equal to 1 of the role, when the master from the synchronization, using--master-data=1,master_log_pos that line is not annotated, will be fully poured into the execution from the library, Master_log_pos will tell you where to start the recovery from the main library.
Log files in the MySQL database
Error log: Logs the error log that the MySQL service process mysqld encountered during startup and shutdown or running
Query log:
Normal query log: Log client connection information and execute SQL statement information
Slow query logs (slow query log): Records an SQL statement that executes longer than the specified value, or an SQL statement that does not have an index (optimized slow query SQL statement is DBA)
Binary logs (binary log): Records information about the data being modified:
Error log: Ending with err in the data directory
Binary log: Bin-log
Normal query log and slow query log generally do not open, log file is too large
For normal logs:
Mysql> Show variables like '%log% ';
Use set to open it:
mysql> Set Global general_log = on; Query OK, 0 rows affected (0.01 sec)
And then randomly create or query several tables, which are recorded in the Localhost.log file.
Slow query: (in/ETC/MY.CNF configuration)
#查询时间超过1秒的sql语句会被记录
Long_query_time=1
#记录没有使用索引的查询
Log_queries_not_using_indexes=1
#记录慢查询日志的文件地址
Slow-query-log-file=/usr/local/mysql/localhost-slow.log
There are 3 modes of Binlog logs.
MySQL Service log vs. backup command