mysql错误日志为aborting_MySQL 错误日志(Error Log)
同大多數(shù)關(guān)系型數(shù)據(jù)庫(kù)一樣,日志文件是MySQL數(shù)據(jù)庫(kù)的重要組成部分。MySQL有幾種不同的日志文件。通常包括錯(cuò)誤日志文件,二進(jìn)制日志,通用日志,慢查詢?nèi)罩?#xff0c;等等。
這些日志能夠幫助我們定位mysqld內(nèi)部發(fā)生的事件,數(shù)據(jù)庫(kù)性能故障,記錄數(shù)據(jù)的變更歷史,用戶恢復(fù)數(shù)據(jù)庫(kù)等等。本文主要描寫敘述錯(cuò)誤日志文件。
1、MySQL日志文件系統(tǒng)的組成
a、錯(cuò)誤日志:記錄啟動(dòng)、運(yùn)行或停止mysqld時(shí)出現(xiàn)的問題。
b、通用日志:記錄建立的client連接和運(yùn)行的語句。
c、更新日志:記錄更改數(shù)據(jù)的語句。該日志在MySQL 5.1中已不再使用。
d、二進(jìn)制日志:記錄全部更改數(shù)據(jù)的語句。
還用于復(fù)制。
e、慢查詢?nèi)罩?#xff1a;記錄全部運(yùn)行時(shí)間超過long_query_time秒的全部查詢或不使用索引的查詢。
f、Innodb日志:innodb redo log
缺省情況下,全部日志創(chuàng)建于mysqld數(shù)據(jù)文件夾中。
能夠通過刷新日志,來強(qiáng)制mysqld來關(guān)閉和又一次打開日志文件(或者在某些情況下切換到一個(gè)新的日志)。
當(dāng)你運(yùn)行一個(gè)FLUSH LOGS語句或運(yùn)行mysqladmin flush-logs或mysqladmin refresh時(shí)。則日志被老化。
對(duì)于存在MySQL復(fù)制的情形下。從復(fù)制server將維護(hù)很多其它日志文件,被稱為接替日志。
2、錯(cuò)誤日志
錯(cuò)誤日志是一個(gè)文本文件。
錯(cuò)誤日志記錄了MySQL Server每次啟動(dòng)和關(guān)閉的具體信息以及運(yùn)行過程中全部較為嚴(yán)重的警告和錯(cuò)誤信息。
能夠用--log-error[=file_name]選項(xiàng)來開啟mysql錯(cuò)誤日志。該選項(xiàng)指定mysqld保存錯(cuò)誤日志文件的位置。
對(duì)于指定--log-error[=file_name]選項(xiàng)而未給定file_name值,mysqld使用錯(cuò)誤日志名host_name.err 并在數(shù)據(jù)文件夾中寫入日志文件。
在mysqld正在寫入錯(cuò)誤日志到文件時(shí)。運(yùn)行FLUSH LOGS 或者mysqladmin flush-logs時(shí)。server將關(guān)閉并又一次打開日志文件。
建議在flush之前手動(dòng)重命名錯(cuò)誤日志文件,之后mysql服務(wù)將使用原始文件名稱打開一個(gè)新文件。
下面為錯(cuò)誤日志備份方法:
shell> mv host_name.err host_name.err-old
shell> mysqladmin flush-logs
shell> mv host_name.err-old backup-directory
3、實(shí)戰(zhàn)演示
#啟用錯(cuò)誤日志,缺省情況下文件名稱為: hostname.err
#下面2種方式均可進(jìn)行錯(cuò)誤日志的配置
--log-error=file_name #命令行選項(xiàng)(command option)log-error=file_Name?? #配置文件(configure file)
#查看當(dāng)前的錯(cuò)誤日志配置,缺省情況下位于數(shù)據(jù)文件夾
mysql> show variables like ‘log_error‘;
+---------------+-------------------------+
| Variable_name | Value?????????????????? |
+---------------+-------------------------+
| log_error???? | /var/lib/mysql/SZDB.err |
+---------------+-------------------------+
1 row in set (0.00 sec)
#查看當(dāng)前mysql server錯(cuò)誤日志文件
SZDB:/var/lib/mysql # tail SZDB.err
140906 22:06:45 InnoDB: Completed initialization of buffer pool
140906 22:06:45 InnoDB: highest supported file format is Barracuda.
140906 22:06:45? InnoDB: Waiting for the background threads to start
140906 22:06:46 InnoDB: 5.5.37 started; log sequence number 1605345
140906 22:06:47 [Note] Server hostname (bind-address): ‘0.0.0.0‘; port: 3306
140906 22:06:47 [Note]?? - ‘0.0.0.0‘ resolves to ‘0.0.0.0‘;
140906 22:06:47 [Note] Server socket created on IP: ‘0.0.0.0‘.
140906 22:06:47 [Note] Event Scheduler: Loaded 0 events
140906 22:06:47 [Note] /usr/sbin/mysqld: ready for connections.
Version: ‘5.5.37-log‘? socket: ‘/var/lib/mysql/mysql.sock‘? port: 3306? MySQL Community Server (GPL)
#停止mysqlserver
SZDB:~ # service mysql stop
Shutting down MySQL....?????????????????????????????????????????????? done
#使用配置文件來設(shè)置log-error參數(shù)
SZDB:~ # echo "log-error=/tmp/SZDB.err">>/etc/my.cnf
SZDB:~ # echo "skip_opt">>/etc/my.cnf???? #加入一個(gè)異常參數(shù)skip_opt
SZDB:~ # grep -v ^# /etc/my.cnf
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-error=/tmp/SZDB.err
skip_opt
#Author : Leshami
#Blog?? :http://blog.csdn.net/leshami
#啟動(dòng)mysqlserver
SZDB:~ # mysqld_safe --user=mysql &
[1] 7315
SZDB:~ # 140907 13:40:33 mysqld_safe Logging to ‘/tmp/SZDB.err‘.
140907 13:40:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140907 13:40:33 mysqld_safe mysqld from pid file /var/lib/mysql/SZDB.pid ended
[1]+? Done??????????????????? mysqld_safe --user=mysql
SZDB:~ # more /tmp/SZDB.err
140907 13:40:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140907 13:40:33 [ERROR] /usr/sbin/mysqld: ambiguous option ‘--skip-opt‘ (--skip-optimizer_prune_level)
140907 13:40:33 [ERROR] Aborting????????? #出現(xiàn)錯(cuò)誤提示為有歧義的參數(shù),實(shí)例終止140907 13:40:33 mysqld_safe mysqld from pid file /var/lib/mysql/SZDB.pid ended
#改動(dòng)my.cnf,刪除skip-opt選項(xiàng)
SZDB:~ # vi /etc/my.cnf
SZDB:~ # grep -v ^# /etc/my.cnf
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log-error=/tmp/SZDB.err
#再次啟動(dòng)mysqlserverSZDB:~ # mysqld_safe --user=mysql &
[1] 7511
SZDB:~ # 140907 13:43:23 mysqld_safe Logging to ‘/tmp/SZDB.err‘.
140907 13:43:23 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
SZDB:~ # more /tmp/SZDB.err
140907 13:40:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140907 13:40:33 [ERROR] /usr/sbin/mysqld: ambiguous option ‘--skip-opt‘ (--skip-optimizer_prune_level)
140907 13:40:33 [ERROR] Aborting
#下面內(nèi)容為正常啟動(dòng)的相關(guān)信息140907 13:40:33 mysqld_safe mysqld from pid file /var/lib/mysql/SZDB.pid ended
140907 13:43:23 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140907 13:43:23 [Note] Plugin ‘FEDERATED‘ is disabled.
140907 13:43:23 InnoDB: The InnoDB memory heap is disabled
140907 13:43:23 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140907 13:43:23 InnoDB: Compressed tables use zlib 1.2.3
140907 13:43:23 InnoDB: Using Linux native AIO
140907 13:43:23 InnoDB: Initializing buffer pool, size = 128.0M
140907 13:43:23 InnoDB: Completed initialization of buffer pool
140907 13:43:23 InnoDB: highest supported file format is Barracuda.
140907 13:43:23? InnoDB: Waiting for the background threads to start
140907 13:43:24 InnoDB: 5.5.37 started; log sequence number 1620641
140907 13:43:25 [Note] Server hostname (bind-address): ‘0.0.0.0‘; port: 3306
140907 13:43:25 [Note]?? - ‘0.0.0.0‘ resolves to ‘0.0.0.0‘;
140907 13:43:25 [Note] Server socket created on IP: ‘0.0.0.0‘.
140907 13:43:25 [Note] Event Scheduler: Loaded 0 events
140907 13:43:25 [Note] /usr/sbin/mysqld: ready for connections.
Version: ‘5.5.37-log‘? socket: ‘/var/lib/mysql/mysql.sock‘? port: 3306? MySQL Community Server (GPL)
從上面的錯(cuò)誤日能夠看出。錯(cuò)誤日志文件的格式。通常例如以下:
時(shí)間? [錯(cuò)誤級(jí)別]? 錯(cuò)誤信息
有些日志信息不一定包括錯(cuò)誤級(jí)別
總結(jié)
以上是生活随笔為你收集整理的mysql错误日志为aborting_MySQL 错误日志(Error Log)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 生物信息考研C语言,四川大学生物信息学初
- 下一篇: 知识图谱论文阅读(十六)【WWW2019