首页 » 数据库 » Mysql日志介绍

Mysql日志介绍

 

mysql有以下几种日志:

  • 错误日志: -log-err
  • 查询日志: -log
  • 慢查询日志: -log-slow-queries
  • 更新日志: -log-update
  • 二进制日志: -log-bin

修改/etc/my.conf

#Enter a name for the error log file.   Otherwise a default name will be used.
   log-error= /var/log/mysql/mysqld.log
#Enter a name for the query log file. Otherwise a default name will be used.
   #log=
#Enter a name for the slow query log file. Otherwise a default name will be used.
   #log-slow-queries=
#Enter a name for the update log file. Otherwise a default name will be used.
   #log-update=
#Enter a name for the binary log. Otherwise a default name will be used.
   #log-bin=

开启了错误日志,开启其它日志去掉注释添加日志路径即可。

#查看启用了哪些日志启用了日志
mysql>show variables like 'log_%';
+----------------------------------------+---------------------------+

| Variable_name                          | Value                     |

+----------------------------------------+---------------------------+

| log_bin                                | OFF                       |

| log_bin_basename                       |                           |

| log_bin_index                          |                           |

| log_bin_trust_function_creators        | OFF                       |

| log_bin_use_v1_row_events              | OFF                       |

| log_error                              | /var/log/mysql/mysqld.log |

| log_output                             | FILE                      |

| log_queries_not_using_indexes          | OFF                       |

| log_slave_updates                      | OFF                       |

| log_slow_admin_statements              | OFF                       |

| log_slow_slave_statements              | OFF                       |

| log_throttle_queries_not_using_indexes | 0                         |

| log_warnings                           | 1                         |

+----------------------------------------+---------------------------+

#怎样知道当前的日志
mysql> show master status;

#看二进制日志文件用mysqlbinlog
mysqlbinlog 日志二进制文件

#或者
mysqlbinlog 日志二进制文件 | tail


原文链接:Mysql日志介绍,转载请注明来源!

0