目录
错误日志
错误日志相关参数
查询日志
查询日志相关参数
慢查询日志
慢查询日志相关参数
二进制日志
二进制日志相关参数
二进制日志的三种记录方式
二进制日志进行数据库恢复
错误日志
错误日志会记录如下信息
mysql执行过程中的错误信息
mysql执行过程中的告警信息
event scheduler运行时所产生信息
mysq启动和停止过程中产生的信息
主从复制结构中,重从服务器IO复杂线程的启动信息
错误日志相关参数
MariaDB [(none)]> show variables where
-> variable_name="log_error" or
-> variable_name="log_warnings";
+---------------+------------------------------------------------------+
| Variable_name | Value |
+---------------+------------------------------------------------------+
| log_error | D:\application\MariaDB 10.4\data\DESKTOP-A3DGD26.err |
| log_warnings | 2 |
+---------------+------------------------------------------------------+
2 rows in set (0.001 sec)
log_error:错误日志的存放路径
log_warnings:表示是否记录告警信息到错误日志,0表示不记录告警信息,1表示记录告警信息,大于1表示各类告警信息,例如有关网络故障的信息和重新连接信息写入错误日志
FILE:
InnoDB: using atomic writes.
2019-09-05 19:32:27 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2019-09-05 19:32:27 0 [Note] InnoDB: Uses event mutexes
2019-09-05 19:32:27 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-09-05 19:32:27 0 [Note] InnoDB: Number of pools: 1
2019-09-05 19:32:27 0 [Note] InnoDB: Using SSE2 crc32 instructions
2019-09-05 19:32:27 0 [Note] InnoDB: Initializing buffer pool, total size = 1G, instances = 1, chunk size = 128M
2019-09-05 19:32:27 0 [Note] InnoDB: Completed initialization of buffer pool
2019-09-05 19:32:27 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
2019-09-05 19:32:27 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-09-05 19:32:27 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-09-05 19:32:27 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
2019-09-05 19:32:27 0 [Note] InnoDB: Waiting for purge to start
2019-09-05 19:32:27 0 [Note] InnoDB: 10.4.7 started; log sequence number 139854; transaction id 21
2019-09-05 19:32:27 0 [Note] InnoDB: Loading buffer pool(s) from D:\application\MariaDB 10.4\data\ib_buffer_pool
2019-09-05 19:32:27 0 [Note] Plugin 'FEEDBACK' is disabled.
2019-09-05 19:32:27 0 [Note] Server socket created on IP: '::'.
2019-09-05 19:32:28 0 [Note] InnoDB: Buffer pool(s) load completed at 190905 19:32:28
2019-09-05 19:32:28 0 [Note] Reading of all Master_info entries succeeded
2019-09-05 19:32:28 0 [Note] Added new Master_info '' to hash table
2019-09-05 19:32:28 0 [Note] D:\application\MariaDB 10.4\bin\mysqld.exe: ready for connections.
Version: '10.4.7-MariaDB' socket: '' port: 3306 mariadb.org binary distribution
2019-09-05 19:35:47 8 [Warning] Access denied for user '13098884691'@'localhost' (using password: NO)
查询日志
查询自然在mysql中被称之为general log,查询日志记录了数据库执行的命令,不管这些语法是否正确,都会被记录。由于数据库操作命令非常多而且比较频繁,
所以开启了查询日志以后,数据库可能需要不停的写入查询,这样会增大服务器的IO压力,增加很多的系统开销,所以默认情况下,mysql的查询日志是没有开启
的,但是开启查询日志也有助于我们分析那些语句执行密集,执行密集的select语句对应的数据是否能够被缓存,查询日志也可以帮助我们分析问题,所以,我
们可以更具实际情况决定是否开启查询日志,如果需要可以手动开启。
查询日志相关参数
MariaDB [(none)]> show variables where variable_name like "%general_log%" or variable_name = "log_output";
+------------------+---------------------+
| Variable_name | Value |
+------------------+---------------------+
| general_log | OFF |
| general_log_file | DESKTOP-A3DGD26.log |
| log_output | FILE |
+------------------+---------------------+
3 rows in set (0.001 sec)
general_log:表示查询日志是否开启,ON表示开启,OFF表示未开启,默认未OFF
log_output:表示当查询日志开启以后,以哪种方式存放。FILE表示存放于文件中,TABLE表示存放于表mysql.general_log中(慢查询