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中繼
- MySQL 狂寫錯誤日誌MySql
- Apche日誌系列(2):錯誤日誌(轉)
- 排查錯誤日誌
- Mysql5.7 的錯誤日誌中最常見的note日誌MySql
- MySQL資料庫中的日誌檔案---(1)錯誤日誌MySql資料庫
- mysql 日誌之普通查詢日誌MySql
- Mabatis配置錯誤日誌BAT
- net 日誌分析錯誤
- 日誌查詢錯誤
- 錯誤日誌檢視
- SQL Server 錯誤日誌SQLServer
- 2、MySQL錯誤日誌(Error Log)詳解MySqlError
- mysql慢查詢和錯誤日誌分析MySql
- jdon框架日誌資訊錯誤框架
- 檢查Linux系統日誌error和mysql錯誤日誌的指令碼薦LinuxErrorMySql指令碼
- mysql 日誌之慢查詢日誌MySql
- mysql日誌MySql
- SAP 錯誤日誌的調查
- node錯誤處理與日誌
- 上一個日誌的錯誤
- Sqlserver:代理錯誤日誌,知多少?SQLServer
- SQL Server ErrorLog 錯誤日誌SQLServerError
- aix ip 衝突錯誤日誌AI
- oracle日誌錯誤恢復(轉)Oracle
- 【MySQL日誌】MySQL日誌檔案初級管理MySql
- ITMySQL錯誤日誌與通用查詢日誌圖文詳析jugMySql
- mysql 日誌之二進位制日誌MySql
- MYSQL啟用日誌和檢視日誌MySql
- 資料緊急修復之啟用錯誤日誌
- Mysql 日誌管理MySql
- MySQL(3)-日誌MySql
- MySQL 五 日誌MySql
- mysql清理日誌MySql
- mysql日誌管理MySql
- 開啟PHP的錯誤log日誌PHP
- 常見的錯誤日誌型別型別
- MySQL 8.0.18 錯誤日誌時間慢了8個小時MySql