Heim  >  Artikel  >  Datenbank  >  MySql Study之--MySql日志管理

MySql Study之--MySql日志管理

WBOY
WBOYOriginal
2016-06-07 16:14:041085Durchsuche

MySqlStudy之--MySql日志管理一、日志文件类型MySQL有几个不同的日志文件,可以帮助你找出mysqld内部发生的事情:日志文件日志文件信息内容错误日志记录启动、运

MySql Study之--MySql日志管理

 

一、日志文件类型

MySQL有几个不同的日志文件,可以帮助你找出mysqld内部发生的事情:

日志文件

日志文件信息内容

错误日志

记录启动、运行或停止mysqld时出现的问题。(log_err)

查询日志

记录建立的客户端连接和执行的语句。

更新日志

记录更改数据的语句,不赞成使用该日志。

二进制日志

记录所有更改数据的语句。还用于复制。(bin_log)

慢日志

记录所有执行时间超过long_query_time秒的所有查询或不使用索引的查询。(slow_query_log)


二、查询日志存放位置

mysql> show variables like '%log%';   +-----------------------------------------+-----------------------------+   | Variable_name                           | Value                       |   +-----------------------------------------+-----------------------------+   | back_log                                | 50                          |   | binlog_cache_size                       | 32768                       |   | binlog_checksum                         | NONE                        |   | binlog_direct_non_transactional_updates | OFF                         |   | binlog_format                           | STATEMENT                   |   | binlog_row_image                        | FULL                        |   | binlog_rows_query_log_events            | OFF                         |   | binlog_stmt_cache_size                  | 32768                       |   | expire_logs_days                        | 0                           |   | general_log                             | OFF                         |   | general_log_file                        | /var/lib/mysql/rh6.log      |   | innodb_flush_log_at_trx_commit          | 1                           |   | innodb_locks_unsafe_for_binlog          | OFF                         |   | innodb_log_buffer_size                  | 8388608                     |   | innodb_log_file_size                    | 5242880                     |   | innodb_log_files_in_group               | 2                           |   | innodb_log_group_home_dir               | ./                          |   | innodb_mirrored_log_groups              | 1                           |   | innodb_undo_logs                        | 128                         |   | log_bin                                 | OFF                         |   | log_bin_basename                        |                             |   | log_bin_index                           |                             |   | log_bin_trust_function_creators         | OFF                         |   | log_error                               | /var/log/mysqld.log         |   | log_output                              | FILE                        |   | log_queries_not_using_indexes           | OFF                         |   | log_slave_updates                       | OFF                         |   | log_warnings                            | 1                           |   | max_binlog_cache_size                   | 18446744073709547520        |   | max_binlog_size                         | 1073741824                  |   | max_binlog_stmt_cache_size              | 18446744073709547520        |   | max_relay_log_size                      | 0                           |   | relay_log                               |                             |   | relay_log_basename                      |                             |   | relay_log_index                         |                             |   | relay_log_info_file                     | relay-log.info              |   | relay_log_info_repository               | FILE                        |   | relay_log_purge                         | ON                          |   | relay_log_recovery                      | OFF                         |   | relay_log_space_limit                   | 0                           |   | slow_query_log                          | OFF                         |   | slow_query_log_file                     | /var/lib/mysql/rh6-slow.log |   | sql_log_bin                             | ON                          |   | sql_log_off                             | OFF                         |   | sync_binlog                             | 0                           |   | sync_relay_log                          | 0                           |   | sync_relay_log_info                     | 0                           |   +-----------------------------------------+-----------------------------+   47 rows in set (0.02 sec)   mysql> show variables like '%log%'; +-----------------------------------------+-----------------------------+ | Variable_name                           | Value                       | +-----------------------------------------+-----------------------------+ | back_log                                | 50                          | | binlog_cache_size                       | 32768                       | | binlog_checksum                         | NONE                        | | binlog_direct_non_transactional_updates | OFF                         | | binlog_format                           | STATEMENT                   | | binlog_row_image                        | FULL                        | | binlog_rows_query_log_events            | OFF                         | | binlog_stmt_cache_size                  | 32768                       | | expire_logs_days                        | 0                           | | general_log                             | OFF                         | | general_log_file                        | /var/lib/mysql/rh6.log      | | innodb_flush_log_at_trx_commit          | 1                           | | innodb_locks_unsafe_for_binlog          | OFF                         | | innodb_log_buffer_size                  | 8388608                     | | innodb_log_file_size                    | 5242880                     | | innodb_log_files_in_group               | 2                           | | innodb_log_group_home_dir               | ./                          | | innodb_mirrored_log_groups              | 1                           | | innodb_undo_logs                        | 128                         | | log_bin                                 | OFF                         | | log_bin_basename                        |                             | | log_bin_index                           |                             | | log_bin_trust_function_creators         | OFF                         | | log_error                               | /var/log/mysqld.log         | | log_output                              | FILE                        | | log_queries_not_using_indexes           | OFF                         | | log_slave_updates                       | OFF                         | | log_warnings                            | 1                           | | max_binlog_cache_size                   | 18446744073709547520        | | max_binlog_size                         | 1073741824                  | | max_binlog_stmt_cache_size              | 18446744073709547520        | | max_relay_log_size                      | 0                           | | relay_log                               |                             | | relay_log_basename                      |                             | | relay_log_index                         |                             | | relay_log_info_file                     | relay-log.info              | | relay_log_info_repository               | FILE                        | | relay_log_purge                         | ON                          | | relay_log_recovery                      | OFF                         | | relay_log_space_limit                   | 0                           | | slow_query_log                          | OFF                         | | slow_query_log_file                     | /var/lib/mysql/rh6-slow.log | | sql_log_bin                             | ON                          | | sql_log_off                             | OFF                         | | sync_binlog                             | 0                           | | sync_relay_log                          | 0                           | | sync_relay_log_info                     | 0                           | +-----------------------------------------+-----------------------------+ 47 rows in set (0.02 sec)

1、错误日志(log_err指定了错误日志的位置)

       错误日志文件包含了当mysqld启动和停止时,以及服务器在运行过程中发生任何严重错误时的相关信息。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn