mysql 日誌之錯誤日誌
錯誤日誌
在mysql資料庫中,錯誤日誌功能是預設開啟的。並且,錯誤日誌無法被禁止。預設情況下,錯誤日誌儲存在mysql資料庫的資料檔案中。錯誤日誌檔案通常的名稱為hostname.err。其中,hostname表示伺服器主機名。
錯誤日誌資訊可以自己進行配置的,錯誤日誌所記錄的資訊是可以透過log-error和log-warnings來定義的,其中log-err是定義是否啟用錯誤日誌的功能和錯誤日誌的儲存位置,log-warnings是定義是否將警告資訊也定義至錯誤日誌中。預設情況下錯誤日誌大概記錄以下幾個方面的資訊:伺服器啟動和關閉過程中的資訊(未必是錯誤資訊,如mysql如何啟動InnoDB的表空間檔案的、如何初始化自己的儲存引擎的等等)、伺服器執行過程中的錯誤資訊、事件排程器執行一個事件時產生的資訊、在從伺服器上啟動伺服器程式時產生的資訊。mysql> SHOW GLOBAL VARIABLES LIKE '%log%';
+-----------------------------------------+---------------------------------------+
| Variable_name | Value |
+-----------------------------------------+---------------------------------------+
| back_log | 80 |
| binlog_cache_size | 32768 |
| binlog_checksum | CRC32 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_error_action | IGNORE_ERROR |
| binlog_format | STATEMENT |
| binlog_gtid_simple_recovery | OFF |
| binlog_max_flush_queue_time | 0 |
| binlog_order_commits | ON |
| binlog_row_image | FULL |
| binlog_rows_query_log_events | OFF |
| binlog_stmt_cache_size | 32768 |
| binlogging_impossible_mode | IGNORE_ERROR |
| expire_logs_days | 0 |
| general_log | OFF |
| general_log_file | /mysql/data/localhost.log |
| innodb_api_enable_binlog | OFF |
| innodb_flush_log_at_timeout | 1 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_compressed_pages | ON |
| innodb_log_file_size | 50331648 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_mirrored_log_groups | 1 |
| innodb_online_alter_log_max_size | 134217728 |
| innodb_undo_logs | 128 |
| log_bin | OFF |
| log_bin_basename | |
| log_bin_index | |
| log_bin_trust_function_creators | OFF |
| log_bin_use_v1_row_events | OFF |
| log_error | /mysql/data/localhost.localdomain.err |
| 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 |
| 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 |
| simplified_binlog_gtid_recovery | OFF |
| slow_query_log | OFF |
| slow_query_log_file | /mysql/data/localhost-slow.log |
| sql_log_bin | ON |
| sql_log_off | OFF |
| sync_binlog | 0 |
| sync_relay_log | 10000 |
| sync_relay_log_info | 10000 |
+-----------------------------------------+---------------------------------------+
61 rows in set (0.00 sec)
log_error可以直接定義為檔案路徑,也可以為ON|OFF;log_warings只能使用1|0來定義開關啟動。
更改錯誤日誌位置可以使用log_error來設定形式如下:
預設的錯誤日誌存放在data目錄下,下面我們修改存放路徑到/mysql/log下
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql3306.sock
datadir = /mysql/data
server-id = 1
log-error = /mysql/log/mysql.log
log-warings = 1 -----這裡刻意寫錯
[root@localhost mysql]# mysqladmin -uroot -proot123 shutdown
Warning: Using a password on the command line interface can be insecure.
150615 09:48:53 mysqld_safe mysqld from pid file /mysql/data/localhost.localdomain.pid ended
[1]+ Done mysqld_safe --defaults-file=/mysql/my.cnf --user=mysql
[root@localhost mysql]# mysqld_safe --defaults-file=/mysql/my.cnf --user=mysql &
[1] 3133
[root@localhost mysql]# 150615 09:49:18 mysqld_safe Logging to '/mysql/log/mysql.log'.
150615 09:49:18 mysqld_safe Starting mysqld daemon with databases from /mysql/data
150615 09:49:20 mysqld_safe mysqld from pid file /mysql/data/localhost.localdomain.pid ended
[1]+ Done mysqld_safe --defaults-file=/mysql/my.cnf --user=mysql
啟動後檢視錯誤日誌
[root@localhost log]# more mysql.log
150615 09:49:18 mysqld_safe Starting mysqld daemon with databases from /mysql/data
2015-06-15 09:49:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server
option (see documentation for more details).
2015-06-15 09:49:18 0 [Note] /mysql/bin/mysqld (mysqld 5.6.25-enterprise-commercial-advanced) starting as process 3289 ...
2015-06-15 09:49:18 3289 [Note] Plugin 'FEDERATED' is disabled.
2015-06-15 09:49:18 3289 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-06-15 09:49:18 3289 [Note] InnoDB: The InnoDB memory heap is disabled
2015-06-15 09:49:18 3289 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-06-15 09:49:18 3289 [Note] InnoDB: Memory barrier is not used
2015-06-15 09:49:18 3289 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-06-15 09:49:18 3289 [Note] InnoDB: Using Linux native AIO
2015-06-15 09:49:18 3289 [Note] InnoDB: Using CPU crc32 instructions
2015-06-15 09:49:18 3289 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-06-15 09:49:18 3289 [Note] InnoDB: Completed initialization of buffer pool
2015-06-15 09:49:18 3289 [Note] InnoDB: Highest supported file format is Barracuda.
2015-06-15 09:49:19 3289 [Note] InnoDB: 128 rollback segment(s) are active.
2015-06-15 09:49:19 3289 [Note] InnoDB: Waiting for purge to start
2015-06-15 09:49:19 3289 [Note] InnoDB: 5.6.25 started; log sequence number 1677570
2015-06-15 09:49:19 3289 [ERROR] /mysql/bin/mysqld: unknown variable 'log-warings=1'
2015-06-15 09:49:19 3289 [ERROR] Aborting
發現日誌已經生效,並且我們寫錯的引數會告出來重新修改引數啟動
[root@localhost mysql]# mysqld_safe --defaults-file=/mysql/my.cnf --user=mysql &
[1] 3687
[root@localhost mysql]# 150615 09:57:59 mysqld_safe Logging to '/mysql/log/mysql.log'.
150615 09:57:59 mysqld_safe Starting mysqld daemon with databases from /mysql/data
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22039464/viewspace-1731504/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 狂寫錯誤日誌MySql
- Mysql5.7 的錯誤日誌中最常見的note日誌MySql
- 排查錯誤日誌
- 日誌查詢錯誤
- net 日誌分析錯誤
- Mabatis配置錯誤日誌BAT
- 2、MySQL錯誤日誌(Error Log)詳解MySqlError
- mysql慢查詢和錯誤日誌分析MySql
- node錯誤處理與日誌
- SAP 錯誤日誌的調查
- Mysql日誌MySql
- 【MySQL日誌】MySQL日誌檔案初級管理MySql
- ITMySQL錯誤日誌與通用查詢日誌圖文詳析jugMySql
- MySQL 8.0.18 錯誤日誌時間慢了8個小時MySql
- 開啟PHP的錯誤log日誌PHP
- python logger 列印日誌錯誤行數Python
- 常見的錯誤日誌型別型別
- MySQL 五 日誌MySql
- Mysql 日誌管理MySql
- MySQL(3)-日誌MySql
- 新特性解讀 | MySQL 8.0錯誤日誌深入過濾(上)MySql
- node專案錯誤處理與日誌
- 關閉Druid中某些錯誤日誌列印UI
- win10系統怎麼檢視系統錯誤日誌_win10如何檢視錯誤日誌Win10
- MySQL日誌管理,舊MySql
- MySQL 事務日誌MySql
- MySQL 的日誌:binlogMySql
- mysql之 slow log 慢查詢日誌MySql
- 如何用NodeJS讀取分析Nginx錯誤日誌NodeJSNginx
- 日誌服務之使用Nginx模式採集日誌Nginx模式
- 日誌分析-apache日誌分析Apache
- Ubuntu下啟動、停止、重啟MySQL,檢視錯誤日誌命令大全UbuntuMySql
- Mysql事件監控日誌MySql事件
- MySQL:慢查詢日誌MySql
- MySQL的日誌總結MySql
- mysql開啟慢日誌MySql
- Mysql-binlog日誌-TMySql
- mysql審計日誌-ProxySQLMySql
- MySQL慢日誌優化MySql優化